diff options
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'}, |