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

Commit 2636054241d298887511fcc3f5763fc1938775a0
Parent: 195f3d7532b9a5054a0fccf8c561c2aa7e92ff0b
Author: mcol <mcol@posteo.net>
Date: 2023-02-16 18:53:27 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2023-02-16 18:53:27 +0000

some group changes

groups.py Modified

@@ -28,10 +28,12 @@
 
 
 groups: list[Group] = [
-    Group("1", label="html", matches=[Match(wm_class="firefox")]),
-    Group("2", label="mail", matches=[Match(wm_class="geary"), Match(title="Geary")]),
-    Group("3", label="term"),
-    Group("4", label="tune", matches=[Match(title="spotify")]),
+    Group("1", label="html"),
+    Group("2", label="disc", matches=[Match(wm_class="discord")]),
+    Group("3", label="mail", matches=[Match(wm_class="evolution")]),
+    Group("4", label="tune", matches=[
+        Match(wm_class="dev.alextren.Spot"), Match(title="Spotify"),
+    ]),
     Group("q", label="term"),
     Group("w", label="term"),
     Group("e", label="term"),
@@ -39,30 +41,26 @@
 ]
 
 
-def _go_to_group(name: str) -> Callable:
+def _go_to_group(qtile: Qtile, name: str) -> None:
     """
     This creates lazy functions that jump to a given group. When there is more than one
     screen, the first 4 and second 4 groups are kept on the first and second screen.
     E.g. going to the fifth group when the first group (and first screen) is focussed
     will also change the screen to the second screen.
     """
-
-    def _inner(qtile: Qtile) -> None:
-        if len(qtile.screens) == 1:
+    if len(qtile.screens) == 1:
+        qtile.groups_map[name].toscreen(toggle=True)
+        return
+
+    old = qtile.current_screen.group.name
+    if name in "1234":
+        qtile.focus_screen(0)
+        if old in "1234" or qtile.current_screen.group.name != name:
+            qtile.groups_map[name].toscreen(toggle=True)
+    else:
+        qtile.focus_screen(1)
+        if old in "qwer" or qtile.current_screen.group.name != name:
             qtile.groups_map[name].toscreen(toggle=True)
-            return
-
-        old = qtile.current_screen.group.name
-        if name in "1234":
-            qtile.focus_screen(0)
-            if old in "1234" or qtile.current_screen.group.name != name:
-                qtile.groups_map[name].toscreen(toggle=True)
-        else:
-            qtile.focus_screen(1)
-            if old in "qwer" or qtile.current_screen.group.name != name:
-                qtile.groups_map[name].toscreen(toggle=True)
-
-    return _inner
 
 
 for i in groups:
@@ -71,7 +69,7 @@
             (
                 [mod],
                 i.name,
-                lazy.function(_go_to_group(i.name)),
+                lazy.function(_go_to_group, i.name),
                 f"Go to group {i.name}",
             ),
             (
@@ -84,33 +82,29 @@
     )
 
 
-def _scroll_screen(direction: int) -> Callable:
+def _scroll_screen(qtile: Qtile, direction: int) -> None:
     """
     Scroll to the next/prev group of the subset allocated to a specific screen. This
     will rotate between e.g. 1->2->3->4->1 when the first screen is focussed.
     """
-
-    def _inner(qtile: Qtile):
-        if len(qtile.screens) == 1:
-            current = qtile.groups.index(qtile.current_group)
-            destination = (current + direction) % 8
-            qtile.groups[destination].toscreen()
-            return
-
+    if len(qtile.screens) == 1:
         current = qtile.groups.index(qtile.current_group)
-        if current < 4:
-            destination = (current + direction) % 4
-        else:
-            destination = ((current - 4 + direction) % 4) + 4
+        destination = (current + direction) % 8
         qtile.groups[destination].toscreen()
+        return
 
-    return _inner
+    current = qtile.groups.index(qtile.current_group)
+    if current < 4:
+        destination = (current + direction) % 4
+    else:
+        destination = ((current - 4 + direction) % 4) + 4
+    qtile.groups[destination].toscreen()
 
 
 keys_group.extend(
     [
-        ([mod], "m", lazy.function(_scroll_screen(1)), "Screen groups forward"),
-        ([mod], "n", lazy.function(_scroll_screen(-1)), "Screen groups backward"),
+        ([mod], "m", lazy.function(_scroll_screen, 1), "Screen groups forward"),
+        ([mod], "n", lazy.function(_scroll_screen, -1), "Screen groups backward"),
     ]
 )