-
Notifications
You must be signed in to change notification settings - Fork 109
/
config.py
280 lines (245 loc) · 8.67 KB
/
config.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import os, subprocess
from libqtile import hook
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.lazy import lazy
from libqtile import layout, bar, widget
# ----------------------------
# -------- Hotkeys -----------
# ----------------------------
mod = "mod4"
keys = [
# Layout hotkeys
Key([mod], "h", lazy.layout.shrink_main()),
Key([mod], "l", lazy.layout.grow_main()),
Key([mod], "j", lazy.layout.down()),
Key([mod], "k", lazy.layout.up()),
Key([mod, "shift"], "j", lazy.layout.shuffle_down()),
Key([mod, "shift"], "k", lazy.layout.shuffle_up()),
Key([mod], "n", lazy.layout.normalize()),
Key([mod], "o", lazy.layout.maximize()),
# Window hotkeys
Key([mod], "space", lazy.window.toggle_fullscreen()),
Key([mod], "c", lazy.window.kill()),
Key([mod, "shift"], "c", lazy.window.kill()),
# Spec hotkeys
Key([mod], "Return", lazy.spawncmd()),
Key([mod, "control"], "r", lazy.restart()),
Key([mod, "control"], "q", lazy.shutdown()),
# Apps hotkeys
Key([mod], "v", lazy.spawn("urxvt")),
Key([mod, "shift"], "v", lazy.spawn("sudo urxvt")),
Key([mod], "y", lazy.spawn("urxvt -e python")),
Key([mod], "g", lazy.spawn("emacsclient -nc -s instance1")),
Key([mod], "b", lazy.spawn("freemind-unstable")),
Key([mod], "z", lazy.spawn("pcmanfm")),
Key([mod], "x", lazy.spawn("deadbeef")),
Key([mod], "Insert", lazy.spawn("firefox -P default")),
Key([mod], "Home", lazy.spawn("firefox -P music")),
Key([mod], "Prior", lazy.spawn("firefox -P default --private-window")),
Key([mod], "Delete", lazy.spawn("firefox -P dev")),
Key([mod], "End", lazy.spawn("firefox -P dev --private-window")),
# System hotkeys
Key([mod, "shift", "control"], "F11", lazy.spawn("sudo hibernate-reboot")),
Key([mod, "shift", "control"], "F12", lazy.spawn("systemctl hibernate")),
Key([], "Print", lazy.spawn("scrot -e 'mv $f /home/user/screenshots/'")),
# Media hotkeys
Key([], 'XF86AudioRaiseVolume', lazy.spawn('pulseaudio-ctl up 5')),
Key([], 'XF86AudioLowerVolume', lazy.spawn('pulseaudio-ctl down 5')),
Key([], 'XF86AudioMute', lazy.spawn('pulseaudio-ctl set 1')),
]
# ----------------------------
# --- Workspaces and Rooms ---
# ----------------------------
# The basic idea behind Workspaces and Rooms is to control
# DIFFERENT subsets of groups with the SAME hotkeys.
# So we can have multiple 'qwerasdf' rooms in a different workspaces.
#
# Qtile Groups are used behind the scenes, but their visibility
# is set dynamically.
def get_group_name(workspace, room):
""" Calculate Group name based on (workspace,room) combination.
"""
return "%s%s" % (room, workspace)
# List of available workspaces.
# Each workspace has its own prefix and hotkey.
workspaces = [
('1', 'F1'),
('2', 'F2'),
('3', '1'),
('4', '2'),
('o', 'o'),
('p', 'p'),
]
# List of available rooms.
# Rooms are identical between workspaces, but they can
# be changed to different ones as well. Minor changes required.
rooms = "qwerasdf"
# Oops, time for a little hack there.
# This is a global object with information about current workspace.
# (viable as config code, not sure about client-server though)
wsp = {
'current': workspaces[0][0], # first workspace is active by default
}
# ... and information about active group in the each workspace.
for w, _ in workspaces:
wsp[w] = {
'active_group': get_group_name(w, rooms[0]) # first room is active by default
}
def get_workspace_groups(workspace):
""" Get list of Groups that belongs to workspace.
"""
return [ get_group_name(workspace, room) for room in rooms]
def to_workspace(workspace):
""" Change current workspace to another one.
"""
def f(qtile):
global wsp
# we need to save current active room(group) somewhere
# to return to it later
wsp[wsp['current']]['active_group'] = qtile.current_group.name
# now we can change current workspace to the new one
# (no actual switch there)
wsp['current'] = workspace
# and navigate to the active group from the workspace
# (actual switch)
qtile.groups_map[
wsp[workspace]['active_group']
].cmd_toscreen(toggle=False)
# we also need to change subset of visible groups in the GroupBox widget
qtile.widgets_map['groupbox'].visible_groups=get_workspace_groups(workspace)
qtile.widgets_map['groupbox'].draw()
# You can do some other cosmetic stuff here.
# For example, change Bar background depending on the current workspace.
# # qtile.widgetMap['groupbox'].bar.background="ff0000"
return f
def to_room(room):
""" Change active room to another within the current workspace.
"""
def f(qtile):
global wsp
qtile.groups_map[get_group_name(wsp['current'], room)].cmd_toscreen(toggle=False)
return f
def window_to_workspace(workspace, room=rooms[0]):
""" Move active window to another workspace.
"""
def f(qtile):
global wsp
qtile.current_window.togroup(wsp[workspace]['active_group'])
return f
def window_to_room(room):
""" Move active window to another room within the current workspace.
"""
def f(qtile):
global wsp
qtile.current_window.togroup(get_group_name(wsp['current'], room))
return f
# Create individual Group for each (workspace,room) combination we have
groups = []
for workspace, hotkey in workspaces:
for room in rooms:
groups.append(Group(get_group_name(workspace, room)))
# Assign individual hotkeys for each workspace we have
for workspace, hotkey in workspaces:
keys.append(Key([mod], hotkey, lazy.function(
to_workspace(workspace))))
keys.append(Key([mod, "shift"], hotkey, lazy.function(
window_to_workspace(workspace))))
# Assign shared hotkeys for each room we have.
# Decision about actual group to open is made dynamically.
for room in rooms:
keys.append(Key([mod], room, lazy.function(
to_room(room))))
keys.append(Key([mod, "shift"], room, lazy.function(
window_to_room(room))))
# ---------------------------
# ---- Layouts & Widgets ----
# ---------------------------
layouts = [
layout.MonadTall(
border_normal=("344152"),
border_focus=("344152"),
border_width=1,
ratio=0.70,
single_border_width=1
)
]
widget_defaults = dict(
font='Arial',
fontsize=12,
padding=3,
)
screens = [
Screen(
top=bar.Bar(
[
widget.GroupBox(
border_width=2,
disable_drag=True,
highlight_method="line",
highlight_color=['#000000', '#000000'],
visible_groups=get_workspace_groups(wsp['current']),
spacing=0,
),
widget.Prompt(
prompt="run: ",
ignore_dups_history=True,
),
widget.WindowName(),
widget.CPUGraph(
width=30,
border_width=1,
border_color="#000000",
frequency=5,
line_width=1,
samples=50,
),
widget.MemoryGraph(
width=30,
border_width=1,
border_color="#000000",
line_width=1,
frequency=5,
fill_color="EEE8AA"
),
widget.Volume(fontsize=10, update_interval=2),
widget.Systray(),
widget.Clock(
format='%a %b %d, %H:%M',
),
widget.CurrentLayoutIcon(scale=0.65),
],
30,
),
)
]
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
]
dgroups_key_binder = None
dgroups_app_rules = []
main = None
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
auto_fullscreen = True
focus_on_window_activation = "smart"
extentions = []
wmname = "LG3D"
floating_layout = layout.Floating(float_rules=[
{'wmclass': 'confirm'},
{'wmclass': 'dialog'},
{'wmclass': 'download'},
{'wmclass': 'error'},
{'wmclass': 'file_progress'},
{'wmclass': 'notification'},
{'wmclass': 'splash'},
{'wmclass': 'toolbar'},
{'wmclass': 'DBeaver'}
])
@hook.subscribe.startup_once
def autostart():
home = os.path.expanduser('~/.config/qtile/autostart.sh')
subprocess.call([home])