An (outdated) collection of plugins for Qtile.
git clone https://github.com/m-col/qtools
Files | Refs | Readme

Commit 8dbf615a323b1de2242c2a6405f3209c4d7bcf5a
Parent: a199c440605e99bebad2262a7903ba220579d2d2
Author: mcol <mcol@posteo.net>
Date: 2020-01-11 11:45:36 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-01-11 11:45:36 +0000

fix timeout and config setting

mpc/mpc.py Modified

@@ -30,8 +30,7 @@
             self.client.connect()
         except ConnectionError:
             pass
-        self.update(func(self))
-        self.show()
+        self.show(func(self))
         self.client.disconnect()
     return _inner
 

amixer/amixer.py Modified

@@ -22,6 +22,7 @@
 
 class Volume(Notifier):
     defaults = [
+        ('summary', 'Volume', 'Notification summary.'),
         ('mixer', 'Master', 'ALSA mixer to control.'),
         ('interval', 5, 'Percentage interval to change volume by.'),
     ]
@@ -62,6 +63,8 @@
 
         if len(stdout) == 5:
             volume = int(stdout[4].decode().split()[3][1:-2])
-        elif len(stdout) == 6:
+        elif len(stdout) == 7:
             volume = int(stdout[5].decode().split()[4][1:-2])
+        else:
+            logger.warning('Output from amixer needs decoding')
         return volume

__init__.py Modified

@@ -28,9 +28,12 @@
             Notifier._is_initted = True
             Notify.init('Qtile')
 
-        Configurable.__init__(self)
+        Configurable.__init__(self, **config)
         self.add_defaults(Notifier.defaults)
-        self._notifier = None
+        self.notifier = Notify.Notification.new(
+            config.get('summary', 'Notifier'), ''
+        )
+        self.timeout = config.get('timeout', -1)
 
     def __getattr__(self, name):
         """
@@ -42,21 +45,19 @@
         return Configurable.__getattr__(self, name)
 
     @property
-    def notifier(self):
-        if self._notifier is None:
-            self._notifier = Notify.Notification.new(self.summary, '')
-            self._notifier.set_timeout(self.timeout)
-        return self._notifier
+    def timeout(self):
+        return self._timeout
 
-    def set_timeout(self, timeout):
-        self.notifier.set_timeout(timeout)
-        self.timeout = timeout
+    @timeout.setter
+    def timeout(self, value):
+        self.notifier.set_timeout(value)
+        self._timeout = value
 
-    def show(self):
+    def show(self, body):
+        if not isinstance(body, str):
+            body = str(body)
+        self.notifier.update(self.summary, body)
         self.notifier.show()
 
     def hide(self):
         self.notifier.hide()
-
-    def update(self, body):
-        self.notifier.update(self.summary, body)