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

Commit 449ddf3371fa052e4a665195b69e241dc4cbc337
Parent: f77a91d0e3b99446651957494b52233de68bc715
Author: mcol <mcol@posteo.net>
Date: 2020-02-29 10:55:53 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-02-29 10:55:53 +0000

clean up following pylint's orders

setup.cfg Modified

@@ -10,5 +10,9 @@
     unused-argument,
     missing-function-doctring,
     missing-module-doctring,
-    access-member-before-definition
+    access-member-before-definition,
+    no-name-in-module,
+    c-extension-no-member
 max-line-length = 88
+max-attributes = 14
+max-args = 10

qtools/rofi_searx/searx.py Modified

@@ -45,7 +45,8 @@
         ('prompt', 'Search the web', 'Prompt displayed by rofi.'),
         ('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.'),
+                                                         'browser. Requires {url} to '
+                                                         'place the search url.'),
         ('notify_on_remove', True, 'Whether to make a notification when removing a '
                                    'searx instance.'),
     ]
@@ -66,9 +67,7 @@
 
     def search(self, qtile=None):
         output = subprocess.run(
-            self.command,
-            stdout=subprocess.PIPE,
-            universal_newlines=True,
+            self.command, stdout=subprocess.PIPE, universal_newlines=True, check=False
         )
         if output.stdout and not output.returncode:
             if self.instances_file:

qtools/notification/notification.py Modified

@@ -153,24 +153,24 @@
         if self.border_width:
             self.border = [self.qtile.color_pixel(c) for c in self.border]
 
-        self._popup_config = {}
+        popup_config = {}
         for opt in Popup.defaults:
             key = opt[0]
             if hasattr(self, key):
                 value = getattr(self, key)
                 if isinstance(value, (tuple, list)):
-                    self._popup_config[key] = value[1]
+                    popup_config[key] = value[1]
                 else:
-                    self._popup_config[key] = value
+                    popup_config[key] = value
 
         for win in range(self.max_windows):
-            popup = Popup(self.qtile, **self._popup_config)
+            popup = Popup(self.qtile, **popup_config)
             popup.win.handle_ButtonPress = self._buttonpress(popup)
             popup.replaces_id = None
             self._hidden.append(popup)
             self._positions.append(
                 (self.x, self.y + win * (self.height + 2 * self.border_width +
-                 self.gap))
+                                         self.gap))
             )
 
         notifier.register(self._notify, Server.capabilities)
@@ -325,26 +325,24 @@
             shown.place()
 
     def _load_icon(self, notif):
-        if notif.app_icon:
-            if notif.app_icon in self._icons:
-                return self._icons.get(notif.app_icon)
-            else:
-                try:
-                    img = images.Img.from_path(notif.app_icon)
-                    if img.width > img.height:
-                        img.resize(width=self.icon_size)
-                    else:
-                        img.resize(height=self.icon_size)
-                    surface, _ = images._decode_to_image_surface(
-                        img.bytes_img, img.width, img.height
-                    )
-                    self._icons[notif.app_icon] = surface, surface.get_height()
-                except (FileNotFoundError, images.LoadingError, IsADirectoryError) as e:
-                    logger.exception(e)
-                    self._icons[notif.app_icon] = None
-                return self._icons[notif.app_icon]
-        else:
+        if not notif.app_icon:
             return None
+        if notif.app_icon in self._icons:
+            return self._icons.get(notif.app_icon)
+        try:
+            img = images.Img.from_path(notif.app_icon)
+            if img.width > img.height:
+                img.resize(width=self.icon_size)
+            else:
+                img.resize(height=self.icon_size)
+            surface, _ = images._decode_to_image_surface(
+                img.bytes_img, img.width, img.height
+            )
+            self._icons[notif.app_icon] = surface, surface.get_height()
+        except (FileNotFoundError, images.LoadingError, IsADirectoryError) as e:
+            logger.exception(e)
+            self._icons[notif.app_icon] = None
+        return self._icons[notif.app_icon]
 
     def close(self, qtile=None):
         """

qtools/mpc/mpc.py Modified

@@ -13,7 +13,7 @@
     }.items()])
 
 """
-# pylint: disable=no-member
+# pylint: disable=no-member,redefined-builtin
 
 from functools import wraps
 

qtools/amixer/amixer.py Modified

@@ -44,58 +44,64 @@
             self.mute_master = False
 
     def increase(self, qtile=None):
-        stdout = self._run(['set', self.mixer, f'{self.interval}%+'])
-        volume = self._get_volume(stdout)
+        stdout = _run(['set', self.mixer, f'{self.interval}%+'])
+        volume = _get_volume(stdout)
         self.show(self.interval * round(volume / self.interval))
 
     def decrease(self, qtile=None):
-        stdout = self._run(['set', self.mixer, f'{self.interval}%-'])
-        volume = self._get_volume(stdout)
+        stdout = _run(['set', self.mixer, f'{self.interval}%-'])
+        volume = _get_volume(stdout)
         self.show(self.interval * round(volume / self.interval))
 
     def toggle(self, qtile=None):
-        stdout = self._run(['set', 'Master' if self.mute_master else self.mixer, 'toggle'])
-        if self._get_mute(stdout):
+        stdout = _run(
+            ['set', 'Master' if self.mute_master else self.mixer, 'toggle']
+        )
+        if _get_mute(stdout):
             self.show('Muted')
         else:
             if self.mute_master:
-                stdout = self._run(['get', self.mixer])
-            volume = self._get_volume(stdout)
+                stdout = _run(['get', self.mixer])
+            volume = _get_volume(stdout)
             self.show(self.interval * round(volume / self.interval))
 
     def mute(self, qtile=None):
-        self._run(['set', 'Master' if self.mute_master else self.mixer, 'mute'])
+        _run(['set', 'Master' if self.mute_master else self.mixer, 'mute'])
         self.show('Muted')
 
     def unmute(self, qtile=None):
-        stdout = self._run(
-            ['set', 'Master' if self.mute_master else self.mixer, 'unmute']
-        )
-        volume = self._get_volume(self._run(['get', self.mixer]))
+        _run(['set', 'Master' if self.mute_master else self.mixer, 'unmute'])
+        volume = _get_volume(_run(['get', self.mixer]))
         self.show(self.interval * round(volume / self.interval))
 
-    def _get_mute(self, stdout):
-        if len(stdout) == 5:
-            if stdout[4].decode().split()[5][1:-1] == 'on':
-                return False
-            else:
-                return True
-        logger.warning('Output from amixer needs decoding')
 
-    def _get_volume(self, stdout):
-        if len(stdout) == 5:
-            return int(stdout[4].decode().split()[3][1:-2])
-        if len(stdout) == 7:
-            return int(stdout[5].decode().split()[4][1:-2])
+def _get_mute(stdout):
+    if len(stdout) == 5:
+        if stdout[4].decode().split()[5][1:-1] == 'on':
+            muted = False
+        else:
+            muted = True
+    else:
+        muted = False
         logger.warning('Output from amixer needs decoding')
-
-    def _run(self, args):
-        cmd = ['amixer']
-        cmd.extend(args)
-        try:
-            output = subprocess.run(cmd, stdout=subprocess.PIPE)
-            stdout = output.stdout.splitlines()
-        except subprocess.CalledProcessError as err:
-            logger.error(err.output.decode())
-            return
-        return stdout
+    return muted
+
+def _get_volume(stdout):
+    if (stdlen:=len(stdout)) == 5:
+        vol = int(stdout[4].decode().split()[3][1:-2])
+    elif stdlen == 7:
+        vol = int(stdout[5].decode().split()[4][1:-2])
+    else:
+        logger.warning('Output from amixer needs decoding')
+        vol = 0
+    return vol
+
+def _run(args):
+    cmd = ['amixer']
+    cmd.extend(args)
+    try:
+        output = subprocess.run(cmd, stdout=subprocess.PIPE, check=False)
+    except subprocess.CalledProcessError as err:
+        logger.error(err.output.decode())
+        return ''
+    return output.stdout.splitlines()

qtools/__init__.py Modified

@@ -3,13 +3,13 @@
 """
 
 
+from random import randint
+
 import gi
 gi.require_version('Notify', '0.7')
 from gi.repository import Notify
 
-from random import randint
 from xcffib.xproto import StackMode
-
 from libqtile import configurable, pangocffi, window
 from libqtile.lazy import lazy
 from libqtile.drawer import Drawer