-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
157 lines (138 loc) · 6.41 KB
/
control.py
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
from libqtile.config import EzDrag, EzKey, Key, KeyChord
from libqtile.lazy import lazy
from libqtile.scratchpad import ScratchPad
class Control:
def __init__(self, env) -> None:
self.env = env
def keys(self):
return [
# {{{ 操作单个窗口
KeyChord(["mod4"], "w", name="Window", submappings=[
EzKey("M-f", lazy.window.toggle_floating()),
EzKey("M-c", lazy.window.center()),
EzKey("M-v", lazy.window.toggle_minimize()),
EzKey("M-q", lazy.window.toggle_fullscreen()),
EzKey("M-x", lazy.window.kill()),
EzKey("M-t", lazy.window.bring_to_front()),
]),
KeyChord(["mod4"], "m", name="MoveWindow", mode=True, submappings=[
EzKey("M-f", lazy.window.toggle_floating()),
EzKey("M-c", lazy.window.center()),
EzKey("M-h", lazy.window.move_floating(-20, 0)),
EzKey("M-l", lazy.window.move_floating(20, 0)),
EzKey("M-j", lazy.window.move_floating(0, 20)),
EzKey("M-k", lazy.window.move_floating(0, -20)),
EzKey("M-y", lazy.window.move_floating(-20, -20)),
EzKey("M-u", lazy.window.move_floating(20, -20)),
EzKey("M-b", lazy.window.move_floating(-20, 20)),
EzKey("M-n", lazy.window.move_floating(20, 20)),
EzKey("M-S-h", lazy.window.resize_floating(-20, 0)),
EzKey("M-S-l", lazy.window.resize_floating(20, 0)),
EzKey("M-S-j", lazy.window.resize_floating(0, 20)),
EzKey("M-S-k", lazy.window.resize_floating(0, -20)),
EzKey("M-S-y", lazy.window.resize_floating(-20, -20)),
EzKey("M-S-u", lazy.window.resize_floating(20, -20)),
EzKey("M-S-b", lazy.window.resize_floating(-20, 20)),
EzKey("M-S-n", lazy.window.resize_floating(20, 20)),
]),
EzKey("M-z", lazy.window.move_up()),
EzKey("M-C-z", lazy.window.move_down()),
# }}}
# {{{ 移动窗口焦点 (保持布局)
EzKey("M-n", lazy.group.next_window()),
EzKey("M-p", lazy.group.prev_window()),
EzKey("M-j", lazy.layout.down()),
EzKey("M-k", lazy.layout.up()),
EzKey("M-h", lazy.layout.left()),
EzKey("M-l", lazy.layout.right()),
# }}}
# {{{ 操作Group
# 显示指定的Group
*(Key(["mod4"], i["key"], lazy.group[i["key"]].toscreen())
for i in self.env.groups),
# 移动窗口到指定的Group
*(Key(["mod4", "control"], i["key"], lazy.window.togroup(i["key"]))
for i in self.env.groups),
# }}}
# {{{ 调整布局 (尺寸稳定)
EzKey("M-C-j", lazy.layout.shuffle_down()),
EzKey("M-C-k", lazy.layout.shuffle_up()),
EzKey("M-C-h", lazy.layout.shuffle_left()),
EzKey("M-C-l", lazy.layout.shuffle_right()),
# }}}
# {{{ 调整布局 (改变尺寸)
EzKey("M-S-s", lazy.layout.toggle_split()),
EzKey("M-S-n", lazy.layout.normalize()),
EzKey("M-S-j", lazy.layout.grow_down()),
EzKey("M-S-k", lazy.layout.grow_up()),
EzKey("M-S-h", lazy.layout.grow_left()),
EzKey("M-S-l", lazy.layout.grow_right()),
# }}}
# {{{ 启动外部程序
EzKey("M-<Return>", lazy.spawn(self.env.cmd_term)),
EzKey("M-r", lazy.spawn(self.env.cmd_launcher)),
EzKey("M-o", bind_window(self.env.groups)),
KeyChord(["mod4"], "e", name="Execute", submappings=[
Key(["mod4"], i["key"], lazy.spawn(i['cmd']))
for i in self.env.cmd_bindings
]),
KeyChord(["mod4"], "y", name="Player", submappings=[
EzKey("M-t", lazy.spawn(self.env.cmd_player_toggle)),
EzKey("M-s", lazy.spawn(self.env.cmd_player_stop)),
EzKey("M-n", lazy.spawn(self.env.cmd_player_next)),
EzKey("M-p", lazy.spawn(self.env.cmd_player_previous)),
EzKey("M-l", lazy.spawn(self.env.cmd_player_loop_toggle)),
]),
KeyChord(["mod4"], "c", name="Capture", submappings=[
EzKey("M-f", lazy.spawn(self.env.cmd_screenshot_fullscreen)),
EzKey("M-s", lazy.spawn(self.env.cmd_screenshot_select)),
EzKey("M-w", lazy.spawn(self.env.cmd_screenshot_window)),
]),
KeyChord(["mod4"], "t", name="ScratchPad", submappings=[
Key(["mod4"], i["key"], lazy.group['default_scratchpad'].
dropdown_toggle(i["name"]))
for i in self.env.dropdowns
]),
# }}}
# {{{ Qtile
KeyChord(["mod4"], "q", [
EzKey("M-r", lazy.reload_config()),
EzKey("M-C-r", lazy.reload_config()),
EzKey("M-C-q", lazy.shutdown()),
], name="Qtile"),
# }}}
# {{{ XF86
Key([], "XF86AudioMute", lazy.spawn(
self.env.cmd_volume_toggle)),
Key([], "XF86AudioLowerVolume", lazy.spawn(
self.env.cmd_volume_decrease)),
Key([], "XF86AudioRaiseVolume", lazy.spawn(
self.env.cmd_volume_increase)),
Key([], "XF86MonBrightnessUp", lazy.spawn(
self.env.cmd_backlight_increase)),
Key([], "XF86MonBrightnessDown", lazy.spawn(
self.env.cmd_backlight_decrease)),
# }}}
]
def mouse(self):
return [
EzDrag("M-1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
EzDrag("M-3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
]
@lazy.function
def bind_window(qtile, groups):
for g in groups:
if g["key"] != qtile.current_group.name:
continue
rule = g["bind_window"]
for w in qtile.windows_map.values():
if hasattr(w, 'group') and w.group \
and not isinstance(w.group, ScratchPad) \
and w.match(rule["match"]):
w.togroup(qtile.current_group.name)
return
qtile.spawn(rule["cmd"])
return
# vim:fdm=marker