summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpanel.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/panel.py b/panel.py
index 93db494..4c9decd 100755
--- a/panel.py
+++ b/panel.py
@@ -462,6 +462,24 @@ class ModMem(ModInterval):
percent = psutil.virtual_memory().percent
self.out = Fmt.labelled('MEM', f'{percent:.0f}%%')
+class ModPWVol(ModInterval):
+ def __init__(self, sink='@DEFAULT_AUDIO_SINK@', **kwargs):
+ super().__init__(**kwargs)
+ self.sink = sink
+
+ def refresh(self):
+ res = subprocess.run(
+ ('wpctl', 'get-volume', self.sink),
+ stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
+ if (m := re.match('Volume: ([0-9.]*)( \[MUTED\])?', res.stdout)):
+ vol = float(m.group(1)) * 100
+ buf = f'{vol:.0f}%%'
+ if m.group(2):
+ buf += ' [muted]'
+ else:
+ buf = Fmt.bg('#a03000', ' error ')
+ self.out = Fmt.labelled('VOL', buf)
+
class Panel:
def __init__(self, *mods, max_paint_delay=0, width=1920, height=22):
self.e_repaint = threading.Event()
@@ -526,7 +544,8 @@ Panel(
ModInputAvail(
'/dev/input/by-id/usb-HID_Keyboard_HID_Keyboard-event-kbd',
unavail_text='NO KEYBOARD'),
- ModNetIf('wg.*', regex=True, label='wg*', interval=1),
+ ModNetIf('wg(?!0$).*', regex=True, label='wg*'),
+ ModPWVol(),
ModCPU(interval=0.5),
ModMem(interval=0.5),
ModDate(