diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-02-19 14:28:10 -0800 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-02-19 14:28:10 -0800 |
commit | 3d5bf4bcf4cc512884be010bc9ef9525e0acb14e (patch) | |
tree | b32b7452e19031c0a03c622ff14e3299f21b7ae6 /panel.py | |
parent | d9d5397f360b7b57353c381a9bbbe2e283650439 (diff) | |
download | panel-3d5bf4bcf4cc512884be010bc9ef9525e0acb14e.tar.gz panel-3d5bf4bcf4cc512884be010bc9ef9525e0acb14e.tar.xz |
add optional indicator when input device is available
Diffstat (limited to 'panel.py')
-rwxr-xr-x | panel.py | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -246,11 +246,17 @@ class ModHLWMTitle(ModHLWMBase): else title) self.repaint() -class ModInputUnavail(Mod): - def __init__(self, path, label='', **kwargs): +class ModInputAvail(Mod): + def __init__(self, path, + avail_text=None, avail_bg='#207000', + unavail_text=None, unavail_bg='#a03000', + **kwargs): super().__init__(**kwargs) self.path = path - self.label = label + self.avail_text = avail_text + self.avail_bg = avail_bg + self.unavail_text = unavail_text + self.unavail_bg = unavail_bg def work(self): p = subprocess.Popen( @@ -284,10 +290,12 @@ class ModInputUnavail(Mod): self._update_state(False) def _update_state(self, avail): - if avail: - self.out = None + if avail and self.avail_text is not None: + self.out = Fmt.bg(self.avail_bg, Fmt.pad(self.avail_text)) + elif not avail and self.unavail_text is not None: + self.out = Fmt.bg(self.unavail_bg, Fmt.pad(self.unavail_text)) else: - self.out = Fmt.bg('#a03000', Fmt.pad(self.label)) + self.out = None self.repaint() class Panel: @@ -336,9 +344,9 @@ Panel( ModHLWMTags(spacing=0), ModHLWMTitle(max_len=96), ModRight(), - ModInputUnavail( + ModInputAvail( '/dev/input/by-id/usb-HID_Keyboard_HID_Keyboard-event-kbd', - label='NO KEYBOARD'), + unavail_text='NO KEYBOARD'), ModDate( fmts=('%Y-%m-%d %H:%M:%S', '%H:%M'), tzs=({'id': None}, {'id': 'UTC'}, |