From c274475635d410c0e9f812e71d20183cb923cd6b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 18 Feb 2024 13:22:42 +0100 Subject: misc updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- xpybar/config/myalsa.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'xpybar/config/myalsa.py') 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 -- cgit v1.2.3-70-g09d2