From ca7fc08d5219dc6c33f67d4e39317aade4490575 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 8 Mar 2024 14:07:35 -0800 Subject: support volume adjustments via mouse --- panel.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/panel.py b/panel.py index 4c9decd..59d4874 100755 --- a/panel.py +++ b/panel.py @@ -478,7 +478,22 @@ class ModPWVol(ModInterval): buf += ' [muted]' else: buf = Fmt.bg('#a03000', ' error ') - self.out = Fmt.labelled('VOL', buf) + + self.out = Fmt.clickable( + 4, f'{id(self)} set 0.05+', + Fmt.clickable( + 5, f'{id(self)} set 0.05-', + Fmt.clickable( + '', f'{id(self)} toggle-mute', + Fmt.labelled('VOL', buf)))) + + def process_cmd(self, cmd): + if cmd == 'toggle-mute': + subprocess.run(('wpctl', 'set-mute', self.sink, 'toggle')) + elif cmd.startswith('set'): + subprocess.run(('wpctl', 'set-volume', self.sink, cmd[4:])) + self.refresh() + self.repaint() class Panel: def __init__(self, *mods, max_paint_delay=0, width=1920, height=22): -- cgit v1.2.3-70-g09d2