qtile: Add swap windows function to swap windows between two groups

This commit is contained in:
Joseph Ferano 2024-07-11 09:37:46 +07:00
parent 7ec983116f
commit 6e221b4ed7

View File

@ -74,6 +74,7 @@ def toggle_language(qtile):
qtile.spawn("setxkbmap -layout us -variant altgr-intl") qtile.spawn("setxkbmap -layout us -variant altgr-intl")
current_language[0] = "en" current_language[0] = "en"
keys = [ keys = [
# A list of available commands that can be bound to keys can be found # 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 # 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() qtile.groups_map[name].toscreen()
return _inner 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: for i in groups:
keys.extend( keys.extend(
[ [
@ -275,6 +287,12 @@ for i in groups:
lazy.window.togroup(i.name, switch_group=False), lazy.window.togroup(i.name, switch_group=False),
desc="Switch to & move focused window to group {}".format(i.name), 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. # Or, use below if you prefer not to switch to that group.
# # mod1 + shift + letter of group = move focused window to group # # mod1 + shift + letter of group = move focused window to group
# Key([mod, "shift"], i.name, lazy.window.togroup(i.name), # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),