My Qtile window manager configuration
git clone https://github.com/m-col/qtile-config
Files | Refs | Readme

Commit cf7eba341a6f5b015530b8aba91ac044045b89d4
Parent: bbc7cc7ec1743ef0c08379a8d1f34b7e94f6fecb
Author: mcol <mcol@posteo.net>
Date: 2021-06-16 22:44:56 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-06-16 22:44:56 +0100

flake8 everything

x11.py Modified

@@ -18,7 +18,8 @@
 
 # Keys to run X11-only launchers
 keys_backend.extend([
-    #([mod],             'd',    lazy.spawn('rofi -show run -theme ~/.config/rofi/common-large.rasi'), "rofi: run"),
+    #([mod],             'd',
+    #   lazy.spawn('rofi -show run -theme ~/.config/rofi/common-large.rasi'), "rofi: run"),
     ([],    'XF86PowerOff',     lazy.spawn('power-menu'),                   "Power menu"),
     ([mod, 'shift'],    'x',    lazy.spawn('set_monitors'),                 "Configure monitors"),
     ([mod, 'shift'],    'i',    lazy.spawn('slock systemctl suspend -i'),   "Suspend system and lock"),

setup.cfg Added

@@ -0,0 +1,5 @@
+[flake8]
+max-line-length = 110
+ignore = 
+    E265, # Block comments should start with "# "
+    E241  # Multiple spaces after ","

scratchpad.py Modified

@@ -21,11 +21,13 @@
 
 if IS_WAYLAND:
     term = "foot "
+    mutt = f"foot -D {HOME}/Downloads mutt"
 else:
     if IS_XEPHYR:
         term = "xterm -e "
     else:
         term = "urxvt -e "
+    mutt = f"urxvt -cd {HOME}/Downloads -e mutt"
 
 
 conf = {
@@ -34,32 +36,30 @@
     "opacity": 1,
 }
 
-
 dropdowns = [
     DropDown("tmux", term + "tmux", height=0.4, **conf),
     DropDown("irc", term + "irc", x=0.1, y=0.05, width=0.8, height=0.9, **conf),
     DropDown("ncmpcpp", term + "ncmpcpp", x=0.12, y=0.2, width=0.56, height=0.7, **conf),
     DropDown("python", term + "python", x=0.05, y=0.1, width=0.2, height=0.3, **conf),
+    DropDown("email", mutt, x=0.1, y=0.05, width=0.8, height=0.9, **conf),
     #DropDown("newsboat", term + "newsboat", x=0.2, y=0.05, width=0.6, height=0.9, **conf),
 ]
 
 
-# Special case because I want to start mutt in ~/Downloads
-if IS_WAYLAND:
-    mutt = DropDown("email", f"foot -D {HOME}/Downloads mutt", x=0.1, y=0.05, width=0.8, height=0.9, **conf)
-else:
-    mutt = DropDown("email", f"urxvt -cd {HOME}/Downloads -e mutt", x=0.1, y=0.05, width=0.8, height=0.9, **conf)
-dropdowns.append(mutt)
-
-
 # Keybindings to open each DropDown
 keys_scratchpad = [
-    ([mod, 'shift'],     'Return',   lazy.group['scratchpad'].dropdown_toggle('tmux'), "Toggle tmux scratchpad"),
-    ([mod, 'control'],   'e',        lazy.group['scratchpad'].dropdown_toggle('email'), "Toggle email scratchpad"),
-    ([mod, 'control'],   'w',        lazy.group['scratchpad'].dropdown_toggle('irc'), "Toggle irc scratchpad"),
-    ([mod, 'control'],   'm', lazy.group['scratchpad'].dropdown_toggle('ncmpcpp'), "Toggle ncmpcpp scratchpad"),
-    ([mod],              'c',        lazy.group['scratchpad'].dropdown_toggle('python'), "Toggle python scratchpad"),
-    #([mod, 'control'],   'n', lazy.group['scratchpad'].dropdown_toggle('newsboat'), "Toggle newsboat scratchpad"),
+    ([mod, 'shift'],     'Return',
+        lazy.group['scratchpad'].dropdown_toggle('tmux'), "Toggle tmux scratchpad"),
+    ([mod, 'control'],   'e',
+        lazy.group['scratchpad'].dropdown_toggle('email'), "Toggle email scratchpad"),
+    ([mod, 'control'],   'w',
+        lazy.group['scratchpad'].dropdown_toggle('irc'), "Toggle irc scratchpad"),
+    ([mod, 'control'],   'm',
+        lazy.group['scratchpad'].dropdown_toggle('ncmpcpp'), "Toggle ncmpcpp scratchpad"),
+    ([mod],              'c',
+        lazy.group['scratchpad'].dropdown_toggle('python'), "Toggle python scratchpad"),
+    #([mod, 'control'],   'n',
+    #    lazy.group['scratchpad'].dropdown_toggle('newsboat'), "Toggle newsboat scratchpad"),
 ]
 
 scratchpad = ScratchPad("scratchpad", dropdowns)

groups.py Modified

@@ -17,7 +17,7 @@
 from libqtile.lazy import lazy
 
 if TYPE_CHECKING:
-    from typing import Callable, List, Tuple
+    from typing import Any, Callable, List, Tuple
 
     from libqtile.core.manager import Qtile
 
@@ -50,13 +50,13 @@
             return
 
         old = qtile.current_screen.group.name
-        if group in '123':
+        if name in '123':
             qtile.focus_screen(0)
-            if old in '123' or qtile.current_screen.group.name != group:
+            if old in '123' or qtile.current_screen.group.name != name:
                 qtile.groups_map[name].cmd_toscreen()
         else:
             qtile.focus_screen(1)
-            if old in 'qwe' or qtile.current_screen.group.name != group:
+            if old in 'qwe' or qtile.current_screen.group.name != name:
                 qtile.groups_map[name].cmd_toscreen()
 
     return _inner

config.py Modified

@@ -7,23 +7,21 @@
 
 import asyncio
 import os
-import sys
 import subprocess
-from functools import partial
 from typing import TYPE_CHECKING
 
-from libqtile import layout, hook, bar, widget, qtile
-from libqtile.config import Key, EzKey, Screen, Group, Drag, Click, Match, ScratchPad, DropDown
+from libqtile import bar, hook, layout, qtile, widget
+from libqtile.config import Drag, Key, Match, Screen
 from libqtile.lazy import lazy
-from libqtile.log_utils import logger
 from libqtile.widget.backlight import ChangeDirection
+from libqtile.widget.battery import Battery, BatteryState
 
 import traverse
 from groups import groups, keys_group
-from scratchpad import scratchpad, keys_scratchpad
+from scratchpad import keys_scratchpad, scratchpad
 
 if TYPE_CHECKING:
-    from typing import List, Tuple
+    from typing import Any, List, Tuple
 
     from libqtile.core.manager import Qtile
 
@@ -32,12 +30,12 @@
 IS_XEPHYR: bool = int(os.environ.get("QTILE_XEPHYR", 0)) > 0
 
 if IS_WAYLAND:
-    from wayland import term, keys_backend, wayland_libinput_config
+    from wayland import keys_backend, term, wayland_libinput_config  # noqa: F401
 else:
-    from x11 import term, keys_backend, wmname
+    from x11 import keys_backend, term, wmname  # noqa: F401
 
 
-## Colours
+# Colours
 theme = dict(
     foreground='#CFCCD6',
     background='#1B2021',
@@ -72,7 +70,7 @@
 # https://coolors.co/1b2021-cfccd6-bbc2e2-b7b5e4-847979
 
 
-## Keys
+# Keys
 
 if IS_XEPHYR:
     mod = "mod1"
@@ -128,16 +126,20 @@
     ([], 'F11',                   lazy.widget['myvolume'].decrease_vol(), "Decrease volume"),
 
     # Backlight control
-    ([], 'XF86MonBrightnessUp',   lazy.widget['backlight'].change_backlight(ChangeDirection.UP, 3),   "Increase backlight"),
-    ([], 'XF86MonBrightnessDown', lazy.widget['backlight'].change_backlight(ChangeDirection.DOWN, 3), "Decrease backlight"),
-    ([], 'F6',                    lazy.widget['backlight'].change_backlight(ChangeDirection.UP, 3),   "Increase backlight"),
-    ([], 'F5',                    lazy.widget['backlight'].change_backlight(ChangeDirection.DOWN, 3), "Decrease backlight"),
+    ([], 'XF86MonBrightnessUp',
+        lazy.widget['backlight'].change_backlight(ChangeDirection.UP, 3),   "Increase backlight"),
+    ([], 'XF86MonBrightnessDown',
+        lazy.widget['backlight'].change_backlight(ChangeDirection.DOWN, 3), "Decrease backlight"),
+    ([], 'F6',
+        lazy.widget['backlight'].change_backlight(ChangeDirection.UP, 3),   "Increase backlight"),
+    ([], 'F5',
+        lazy.widget['backlight'].change_backlight(ChangeDirection.DOWN, 3), "Decrease backlight"),
 
     # Launchers
     ([mod],             'd',        lazy.spawncmd(),                            "Spawn with Prompt"),
     ([mod],             'Return',   lazy.spawn(term),                           "Spawn terminal"),
     ([mod, 'shift'],    'f',        lazy.spawn("firefox"),                      "Spawn Firefox"),
-    ([mod, 'control'],  'f',        lazy.spawn("tor-browser --allow-remote") ,  "Spawn Tor Browser"),
+    ([mod, 'control'],  'f',        lazy.spawn("tor-browser --allow-remote"),   "Spawn Tor Browser"),
     ([],                'Print',    lazy.spawn("screenshot copy"),              "Screenshot to clipboard"),
     (['shift'],         'Print',    lazy.spawn('screenshot'),                   "Screenshot to file"),
     ([mod],             'p',        lazy.spawn('get_password_rofi'),            "Keepass passwords"),
@@ -145,16 +147,14 @@
 ])
 
 
-## Mouse control
+# Mouse control
 mouse = [
-    Drag([mod], "Button1",      lazy.window.set_position_floating(),    start=lazy.window.get_position()),
+    Drag([mod], "Button1",      lazy.window.set_position_floating(), start=lazy.window.get_position()),
     Drag([mod, alt], "Button1", lazy.window.set_size_floating(), start=lazy.window.get_size()),
-    Click([mod], "Button4",     lazy.layout.grow_up()),
-    Click([mod], "Button5",     lazy.layout.grow_down()),
 ]
 
 
-## Layouts
+# Layouts
 border_focus = [colours[13], colours[5]]
 #border_focus = colours[13]
 border_normal = background
@@ -168,24 +168,24 @@
 
 layouts = [
     layout.Columns(
-        insert_position = 1,
-        border_width = bw,
-        border_focus = border_focus,
-        border_normal = border_normal,
-        border_on_single = True,
-        wrap_focus_columns = False,
-        wrap_focus_rows = False,
-        margin = inner_gaps,
-        corner_radius = cw,
+        insert_position=1,
+        border_width=bw,
+        border_focus=border_focus,
+        border_normal=border_normal,
+        border_on_single=True,
+        wrap_focus_columns=False,
+        wrap_focus_rows=False,
+        margin=inner_gaps,
+        corner_radius=cw,
     ),
     layout.Max(),
 ]
 
 floating_layout = layout.Floating(
-    border_width = bw,
-    border_focus = border_focus,
-    border_normal = border_normal,
-    corner_radius = cw,
+    border_width=bw,
+    border_focus=border_focus,
+    border_normal=border_normal,
+    corner_radius=cw,
     float_rules=[
         Match(title='wlroots - X11-1'),
         Match(title='wlroots - X11-2'),
@@ -219,7 +219,7 @@
 )
 
 
-## Screens and Bars
+# Screens and Bars
 widget_defaults = {
     'padding': 10,
     'foreground': foreground,
@@ -278,6 +278,7 @@
     foreground=colours[3],
 )
 
+
 class MyVolume(widget.Volume):
     def _configure(self, qtile, bar):
         widget.Volume._configure(self, qtile, bar)
@@ -314,10 +315,12 @@
         subprocess.call('amixer set PCM 4%+'.split())
         self.volume = self.get_volume()
         self._update_drawer()
+
     def cmd_decrease_vol(self):
         subprocess.call('amixer set PCM 4%-'.split())
         self.volume = self.get_volume()
         self._update_drawer()
+
     def cmd_mute(self):
         subprocess.call('amixer set Master toggle'.split())
         self.channel = 'Master'
@@ -327,6 +330,7 @@
             self.volume = self.get_volume()
         self._update_drawer()
 
+
 volume = MyVolume(
     fontsize=18,
     channel='PCM',
@@ -347,7 +351,7 @@
     update_interval=5,
 )
 
-from libqtile.widget.battery import Battery, BatteryState
+
 class MyBattery(Battery):
     def build_string(self, status):
         if self.layout is not None:
@@ -377,12 +381,12 @@
         self.timer_setup()
 
     def button_press(self, x, y, button):
-        old = self.format
         self.format = '{percent:2.0%}'
-        self.font='TamzenForPowerline Bold'
+        self.font = 'TamzenForPowerline Bold'
         self.timer_setup()
         self.timeout_add(1, self.restore)
 
+
 battery = MyBattery(
     format='{char}',
     low_foreground=colours[1],
@@ -410,6 +414,7 @@
     widget.GroupBox(**groupbox_config, visible_groups=['q', 'w', 'e']),
 ]
 
+
 @hook.subscribe.startup
 def _():
     # Set up initial GroupBox visible groups
@@ -418,6 +423,7 @@
     else:
         groupboxes[0].visible_groups = ['1', '2', '3', 'q', 'w', 'e']
 
+
 @hook.subscribe.screen_change
 async def _(_):
     # Reconfigure GroupBox visible groups
@@ -475,7 +481,7 @@
 ]
 
 
-## Config variables
+# Config variables
 reconfigure_screens = True
 follow_mouse_focus = True
 bring_front_click = True