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

Commit 34cad2a53579e3ef78b08e6321a305160c861d8c
Parent: f03bb06d135d30d73b37530d9ea03166baf124a5
Author: mcol <mcol@posteo.net>
Date: 2020-01-12 19:42:20 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-01-12 19:42:20 +0000

add smooth backlight change, and notify on searx instance removal

qtools/rofi_searx/searx.py Modified

@@ -46,6 +46,8 @@
         ('theme', None, 'rofi theme to use.'),
         ('launcher', 'tor-browser --allow-remote {url}', 'Command used to open web '
                      'browser. Requires {url} to place the search url.'),
+        ('notify_on_remove', True, 'Whether to make a notification when removing a '
+                                   'searx instance.'),
     ]
 
     def __init__(self, **config):
@@ -88,6 +90,8 @@
             if self.instances_file:
                 self.instances.append(f'#{self.last_used}')
                 self.save_instances()
+            if self.notify_on_remove:
+                self.show(self.last_used)
             self.last_used = None
 
     def load_instances(self, qtile=None):

qtools/backlight/backlight.py Modified

@@ -13,11 +13,15 @@
 """
 
 import os
+import time
 
 from libqtile.log_utils import logger
 from qtools import Notifier
 
 
+_transition = 80
+
+
 class Backlight(Notifier):
     """
     This class controls screen backlight by directly reading and writing to the
@@ -26,6 +30,7 @@
     defaults = [
         ('summary', 'Backlight', 'Notification summary.'),
         ('interval', 10, 'Percentage interval by which to change backlight'),
+        ('smooth', True, 'Whether to smoothly change brightness level.'),
         (
             'path',
             '/sys/class/backlight/nv_backlight/brightness',
@@ -36,31 +41,45 @@
     def __init__(self, **config):
         Notifier.__init__(self, **config)
         self.add_defaults(Backlight.defaults)
+        self.transition = _transition / self.interval / 1000
 
         if not os.path.isfile(self.path):
             logger.error('Path passed to Backlight plugin is invalid')
             self.path = '/dev/null'
 
-    @property
-    def brightness(self):
+    def inc_brightness(self, qtile=None):
+        self.change(1)
+
+    def dec_brightness(self, qtile=None):
+        self.change(-1)
+
+    def change(self, direction):
+        start = self.get_brightness()
+        end = self.check_value(start + self.interval * direction)
+        self.show(end)
+
+        if self.smooth:
+            for i in range(
+                start + direction,
+                end + direction,
+                direction
+            ):
+                with open(self.path, 'w') as f:
+                    f.write(str(i))
+                time.sleep(self.transition)
+        else:
+            with open(self.path, 'w') as f:
+                f.write(str(end))
+
+    def get_brightness(self):
         with open(self.path, 'r') as f:
             return int(f.read())
 
-    @brightness.setter
-    def brightness(self, value):
+    def check_value(self, value):
         if value > 100:
             value = 100
         elif value < 0:
             value = 0
         elif value % self.interval:
             value = self.interval * round(value / self.interval)
-
-        with open(self.path, 'w') as f:
-            f.write(str(value))
-        self.show(value)
-
-    def inc_brightness(self, qtile=None):
-        self.brightness += self.interval
-
-    def dec_brightness(self, qtile=None):
-        self.brightness -= self.interval
+        return value