aboutsummaryrefslogtreecommitdiffstats
path: root/xpybar/config/myalsa.py
diff options
context:
space:
mode:
Diffstat (limited to 'xpybar/config/myalsa.py')
-rw-r--r--xpybar/config/myalsa.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/xpybar/config/myalsa.py b/xpybar/config/myalsa.py
index 552c459..ef246c0 100644
--- a/xpybar/config/myalsa.py
+++ b/xpybar/config/myalsa.py
@@ -4,6 +4,11 @@ import alsaaudio
from common import *
+class MixerAction:
+ def __init__(self, name, action):
+ self.name = name
+ self.action = action
+
class MyALSA(Entry):
def __init__(self, *args, timeout = None, sleep = None, cards = -1, mixers = None, colours = {}, prefix = '', **kwargs): ## TODO support multiple cards and all mixers
self.colours = colours if colours is not None else {}
@@ -28,6 +33,7 @@ class MyALSA(Entry):
else:
cards = cards
self.alsa = []
+ self.actions = []
names = {}
for index in alsaaudio.card_indexes():
for name in alsaaudio.card_name(index):
@@ -36,6 +42,11 @@ class MyALSA(Entry):
card = names.get(card, card)
for mixer in mixers: ## TODO support by name (and 'default')
try:
+ if isinstance(mixer, MixerAction):
+ self.actions.append(mixer.action)
+ mixer = mixer.name
+ else:
+ self.actions.append(None)
if isinstance(mixer, tuple) or isinstance(mixer, list):
self.alsa.append([ALSA(card, m) for m in mixer])
else:
@@ -112,7 +123,8 @@ class MyALSA(Entry):
channel = -1
break
col -= 1
-
+
+ action = self.actions[mixer]
mixer = self.alsa[mixer]
if isinstance(mixer, list):
if button == LEFT_BUTTON:
@@ -125,6 +137,10 @@ class MyALSA(Entry):
volume = mixer.get_volume()
volume = limited(sum(volume) / len(volume))
mixer.set_volume(volume, -1)
+ elif button == MIDDLE_BUTTON:
+ if action is not None:
+ print('middle click: ' + str(action is not None))
+ action()
elif button in (SCROLL_UP, SCROLL_DOWN):
volume = mixer.get_volume()
adj = -5 if button == SCROLL_DOWN else 5