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

Commit 54d7075e9d3eef589a6b711c989e7334ed857f4e
Parent: 3e82be7e7aa6f5966d7c1f70c9f0a8c91b75b364
Author: mcol <mcol@posteo.net>
Date: 2021-06-16 00:03:53 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-06-16 00:03:53 +0100

Put scratchpad configuration into own file

scratchpad.py Added

@@ -0,0 +1,65 @@
+"""
+Scratchpad and DropDowns
+========================
+
+The scratchpads are the same with either backend, but the terminal used differs. I
+prefer these terminals over something like alacritty, which would be an easier
+alternative to configure because it works under both Wayland and X.
+"""
+
+import os
+
+from libqtile import qtile
+from libqtile.config import DropDown, ScratchPad
+from libqtile.lazy import lazy
+
+HOME: str = os.path.expanduser('~')
+IS_WAYLAND: bool = qtile.core.name == "wayland"
+IS_XEPHYR: bool = int(os.environ.get("QTILE_XEPHYR", 0)) > 0
+mod = "mod1" if IS_XEPHYR else "mod4"
+
+
+if IS_WAYLAND:
+    term = "foot "
+else:
+    if IS_XEPHYR:
+        term = "xterm -e "
+    else:
+        term = "urxvt -e "
+
+
+conf = {
+    "warp_pointer": False,
+    "on_focus_lost_hide": True,
+    "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("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"),
+]
+
+scratchpad = ScratchPad("scratchpad", dropdowns)

config.py Modified

@@ -20,6 +20,7 @@
 
 import traverse
 from groups import groups, keys_group
+from scratchpad import scratchpad, keys_scratchpad
 
 if TYPE_CHECKING:
     from typing import List, Tuple
@@ -433,45 +434,6 @@
 ]
 
 
-# Dropdowns and Scratchpad
-
-dd_defaults = {
-    "warp_pointer": False,
-    "on_focus_lost_hide": True,
-    "opacity": 1,
-}
-
-if IS_WAYLAND:
-    dropdowns = [
-        DropDown("tmux", "foot tmux", height=0.4, **dd_defaults),
-        DropDown("email", f"foot -D {HOME}/Downloads mutt", x=0.1, y=0.05, width=0.8, height=0.9, **dd_defaults),
-        DropDown("irc", "foot irc", x=0.1, y=0.05, width=0.8, height=0.9, **dd_defaults),
-        DropDown("ncmpcpp", "foot ncmpcpp", x=0.12, y=0.2, width=0.56, height=0.7, **dd_defaults),
-        DropDown("python", "foot python", x=0.05, y=0.1, width=0.2, height=0.3, **dd_defaults),
-        #DropDown("newsboat", "foot newsboat", x=0.2, y=0.05, width=0.6, height=0.9, **dd_defaults),
-    ]
-else:
-    dropdowns = [
-        DropDown("tmux", "urxvt -e tmux", height=0.4, **dd_defaults),
-        DropDown("email", f"urxvt -cd {HOME}/Downloads -e mutt", x=0.1, y=0.05, width=0.8, height=0.9, **dd_defaults),
-        DropDown("irc", "urxvt -b 100 -e irc", x=0.1, y=0.05, width=0.8, height=0.9, **dd_defaults),
-        DropDown("ncmpcpp", "urxvt -e ncmpcpp", x=0.12, y=0.2, width=0.56, height=0.7, **dd_defaults),
-        DropDown("python", "urxvt -e python", x=0.05, y=0.1, width=0.2, height=0.3, **dd_defaults),
-        #DropDown("newsboat", "urxvt -e newsboat", x=0.2, y=0.05, width=0.6, height=0.9, **dd_defaults),
-    ]
-
-groups.append(ScratchPad("scratchpad", dropdowns))
-
-my_keys.extend([
-    ([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"),
-])
-
-
 # Hooks
 
 @hook.subscribe.startup
@@ -547,15 +509,15 @@
             qtile.cmd_reconfigure_screens()
 
 
-## General settings
+## Config variables
 reconfigure_screens = True
 follow_mouse_focus = True
 bring_front_click = True
 cursor_warp = False
 auto_fullscreen = True
 focus_on_window_activation = 'smart'
+groups.append(scratchpad)
 
-
-# Reformat keys
 my_keys.extend(keys_group)
+my_keys.extend(keys_scratchpad)
 keys = [Key(mods, key, cmd, desc=desc) for mods, key, cmd, desc in my_keys]