Files
dotfiles/qtile/modules/groups.py

145 lines
3.8 KiB
Python
Raw Normal View History

2025-09-30 19:35:36 +02:00
# groups.py (überarbeitete Version)
2025-08-17 11:53:34 +02:00
import re
from libqtile.lazy import lazy
from libqtile.config import Group, EzKey as Key, Match, DropDown, ScratchPad
2025-09-30 19:35:36 +02:00
# WICHTIG: Definiere hier group_screen_map und groups
2025-08-17 11:53:34 +02:00
group_screen_map = {
2025-09-30 19:35:36 +02:00
"0": 0,
2025-08-17 11:53:34 +02:00
"1": 1,
"2": 1,
"3": 1,
"4": 0,
"5": 0,
"6": 0,
"7": 2,
"8": 2,
"9": 2,
"f1": 0,
"f2": 2,
"f3": 0,
"f4": 2,
"f5": 2,
"f6": 2,
"f7": 0,
"f8": 1,
"f9": 1,
"f10": 1,
"f11": 1,
"f12": 1,
}
groups = [
Group(
name="0",
label="󰓓",
2025-09-30 19:35:36 +02:00
matches=[Match(wm_class=re.compile(r"^(steam|Minecraft*)"))],
2025-08-17 11:53:34 +02:00
),
Group(name="1", label="󰲡"),
Group(name="2", label="󰲣"),
Group(name="3", label="󰲥"),
Group(name="4", label="󰲧"),
Group(name="5", label="󰲩"),
Group(name="6", label="󰲫"),
Group(name="7", label="󰲭"),
Group(name="8", label="󰲯"),
Group(name="9", label="󰲱"),
# Groups on function-keys
2025-09-30 19:35:36 +02:00
Group(name="f1", label="", matches=[Match(wm_class=re.compile(r"^(firefox)$"))]),
2025-08-17 11:53:34 +02:00
Group(name="f2", label="", matches=[Match(wm_class="discord")]),
2025-09-30 19:35:36 +02:00
Group(name="f3", label="", matches=[Match(wm_class=re.compile(r"^(joplin)$"))]),
2025-08-17 11:53:34 +02:00
Group(
name="f4",
label="",
2025-09-30 19:35:36 +02:00
matches=[Match(wm_class=re.compile(r"^(com.github.th_ch.youtube_music)$"))],
2025-08-17 11:53:34 +02:00
),
2025-09-30 19:35:36 +02:00
Group(name="f5", label="󱦹", matches=[Match(wm_class="rnote")]),
Group(name="f6", label="󰟵", matches=[Match(wm_class="bitwarden")]),
Group(name="f7", label=" 󰣀", matches=[Match(wm_class=re.compile(r"^(XPipe)$"))]),
2025-08-17 11:53:34 +02:00
Group(name="f8", label="󱊲"),
Group(name="f9", label="󱊳"),
Group(name="f10", label="󱊴"),
Group(name="f11", label="󱊵"),
Group(name="f12", label="󱊶"),
]
2025-09-30 19:35:36 +02:00
# Füge die Scratchpad-Gruppe zur Gruppenliste hinzu
2025-08-17 11:53:34 +02:00
groups.append(
ScratchPad(
"scratchpad",
[
DropDown(
"term",
"kitty",
width=0.4,
height=0.5,
x=0.3,
y=0.25,
opacity=1,
on_focus_lost_hide=True,
),
DropDown(
"calc",
"qalculate-gtk",
width=0.3,
height=0.6,
x=0.35,
y=0.2,
opacity=1,
on_focus_lost_hide=False,
),
],
)
)
2025-09-30 19:35:36 +02:00
def go_to_group(name: str):
def _inner(qtile):
screen = group_screen_map.get(name, 0)
if len(qtile.screens) <= 2:
qtile.groups_map[name].toscreen()
else:
qtile.focus_screen(screen)
qtile.groups_map[name].toscreen()
return _inner
def go_to_group_and_move_window(name: str):
def _inner(qtile):
screen = group_screen_map.get(name, 0)
qtile.current_window.togroup(name, switch_group=False)
if len(qtile.screens) > 2:
qtile.focus_screen(screen)
qtile.groups_map[name].toscreen()
return _inner
def get_group_keys(mod: str) -> list:
"""
Diese Funktion erstellt und gibt alle Key-Bindings für die Gruppen zurück.
Sie nimmt den Modifier-Key (z.B. "M") als Argument.
"""
keys = []
# Fügt Keys für reguläre Gruppen und F-Tasten-Gruppen hinzu
for group in groups:
# Hier wird der Name der Gruppe als Key verwendet, außer bei Scratchpads
if group.name != "scratchpad":
# Normale Gruppen wechseln
keys.append(
Key(f"M-{group.name}", lazy.function(go_to_group(group.name))),
)
# Fenster in Gruppe verschieben
keys.append(
Key(
f"M-S-{group.name}",
lazy.function(go_to_group_and_move_window(group.name)),
),
)
return keys