aboutsummaryrefslogtreecommitdiff
path: root/linux/qtile/config/group.m4.py
blob: abb64a6766303944efc48bcf9ee8ece780b9d553 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
groups = [
    Group(name="1"),
    Group(name="2"),
    Group(name="3"),
    Group(name="4"),
    Group(name="5"),
    Group(name="6"),
    Group(name="7"),
    Group(name="8"),
    Group(name="9"),
]

group_screen_map = dict()

def to_group(name: str):
    def _inner(qtile):
        g = qtile.groups_map[name]
        if (sc := group_screen_map[name]) is not None:
            if sc < num_monitors:
                qtile.to_screen(sc)
        g.toscreen()
    return _inner


for g in groups:
    group_screen_map[g.name] = None
    keys.extend(
        [
            Key(
                [mod],
                g.name,
                lazy.function(to_group(g.name)),
                desc="Switch to group {}".format(g.name),
            ),
            Key(
                [mod, "shift"],
                g.name,
                lazy.window.togroup(g.name),
                desc="move focused window to group {}".format(g.name)
            ),
        ]
    )

@hook.subscribe.group_window_add
def group_window_add(group, window):
    groups = qtile.get_groups()
    global group_screen_map
    group_screen_map[group.name] = groups[group.name]["screen"]
    logger.warning(group_screen_map)


@hook.subscribe.delgroup
def group_deleted(group_name):
    send_notification("qtile", f"Group deleted: {group_name}")

@hook.subscribe.setgroup
def setgroup():
    send_notification("qtile", "Group set")


@hook.subscribe.changegroup
def change_group():
    send_notification("qtile", "Change group event")

@hook.subscribe.addgroup
def group_added(group_name):
    send_notification("qtile", f"New group added: {group_name}")