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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# Qtile Config File
# http://www.qtile.org/
# Justine Smithies
# https://git.sr.ht/~justinesmithies/dotfiles
# Hooks configuration
import asyncio
import os
import subprocess
import time
from libqtile import qtile
from libqtile import hook
from groups import groups
from libqtile.log_utils import logger
@hook.subscribe.startup_once
def autostart():
home = os.path.expanduser('~')
subprocess.Popen([home + '/.config/qtile/autostart.sh'])
# Reload config on screen changes
@hook.subscribe.screens_reconfigured
async def outputs_changed():
logger.warning("Screens reconfigured")
await asyncio.sleep(1)
logger.warning("Reloading config...")
qtile.reload_config()
# When application launched automatically focus it's group
@hook.subscribe.client_new
def modify_window(client):
for group in groups: # follow on auto-move
match = next((m for m in group.matches if m.compare(client)), None)
if match:
targetgroup = client.qtile.groups_map[group.name] # there can be multiple instances of a group
targetgroup.toscreen(toggle=False)
break
# Hook to fallback to the first group with windows when last window of group is killed
# @hook.subscribe.client_killed
# def fallback(window):
# if window.group.windows != [window]:
# if isinstance(window, base.Static) or window.group.windows != [window]:
# return
# idx = qtile.groups.index(window.group)
# for group in qtile.groups[idx - 1::-1]:
# if group.windows:
# qtile.current_screen.toggle_group(group)
# return
# qtile.current_screen.toggle_group(qtile.groups[0])
# Work around for matching Spotify
@hook.subscribe.client_new
def slight_delay(window):
time.sleep(0.04)
# If Spotify opens move it to group 6
@hook.subscribe.client_name_updated
def spotify(window):
if window.name == 'Spotify':
window.togroup(group_name='阮 ₆')
# If mpv opens float it at pos x, y, w, h, borderwidth, border color
@hook.subscribe.client_managed
def repos(window):
if window.get_wm_class() and 'mpv' in window.get_wm_class():
window.floating = True
window.place(1200, 650, 640, 360, 2, "#ffffff")
# If 'libreoffice' opens toggle floating off
@hook.subscribe.client_new
def libreoffice(window):
wm_class = window.get_wm_class()
if wm_class is None:
wm_class = []
if [x for x in wm_class if x.startswith("libreoffice")]:
window.disable_floating()
|