From 6e221b4ed70a1b255ca789f98acf77ec0bf8d134 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Thu, 11 Jul 2024 09:37:46 +0700 Subject: [PATCH] qtile: Add swap windows function to swap windows between two groups --- .config/qtile/config.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.config/qtile/config.py b/.config/qtile/config.py index c11040f..d6b8f9e 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -58,7 +58,7 @@ def kbd_brightness_up(qtile): current_kbd_light[0] = min(len(kbd_lights) - 1, idx+1) value = kbd_lights[current_kbd_light[0]] qtile.spawn(f"asusctl -k {value}") - + def kbd_brightness_down(qtile): idx = current_kbd_light[0] current_kbd_light[0] = max(0, idx-1) @@ -74,6 +74,7 @@ def toggle_language(qtile): qtile.spawn("setxkbmap -layout us -variant altgr-intl") current_language[0] = "en" + keys = [ # A list of available commands that can be bound to keys can be found # at https://docs.qtile.org/en/latest/manual/config/lazy.html @@ -257,6 +258,17 @@ def go_to_group(name: str) -> Callable: qtile.groups_map[name].toscreen() return _inner +def swap_windows(name: str) -> Callable: + def _inner(qtile) -> None: + other_windows = [*qtile.groups_map[name].windows] + current_windows = [*qtile.current_group.windows] + for win in current_windows: + win.togroup(name) + for win in other_windows: + win.togroup(qtile.current_group.name) + + return _inner + for i in groups: keys.extend( [ @@ -275,6 +287,12 @@ for i in groups: lazy.window.togroup(i.name, switch_group=False), desc="Switch to & move focused window to group {}".format(i.name), ), + Key( + [mod, "control"], + i.name, + lazy.function(swap_windows(i.name)), + desc="Swap all windows with windows from N group".format(i.name), + ), # Or, use below if you prefer not to switch to that group. # # mod1 + shift + letter of group = move focused window to group # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),