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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
local awful = require "awful"
local backlight = require "services.backlight"
local beautiful = require "beautiful"
local cfg = require "misc.cfg"
local fresnel = require "ui.fresnel"
local gtable = require "gears.table"
local gtimer = require "gears.timer"
local insightful = require "ui.insightful"
local naughty = require "naughty"
-- local mpris = (require "services.mpris")
local mpris = require "ui.statusbar.panel.widgets.mpris"
local playerctl = require "services.playerctl"
local powermenu = require "ui.powermenu"
local qbind = require "quarrel.bind"
local recording = { false, "" }
client.connect_signal("request::default_mousebindings", function()
awful.mouse.append_client_mousebindings {
qbind {
triggers = qbind.btns.left,
press = function(c)
c:activate {
context = "mouse_click",
}
end,
group = "client",
desc = "raise client",
},
qbind {
mods = qbind.mods.M,
triggers = qbind.btns.left,
press = function(c)
c:activate {
context = "mouse_click",
action = "mouse_move",
}
end,
group = "client",
desc = "move client",
},
qbind {
mods = qbind.mods.M,
triggers = qbind.btns.right,
press = function(c)
c:activate {
context = "mouse_click",
action = "mouse_resize",
}
end,
group = "client",
desc = "resize client",
},
}
end)
client.connect_signal("request::default_keybindings", function()
awful.keyboard.append_client_keybindings {
qbind {
mods = qbind.mods.MC,
triggers = "q",
press = function(c)
c:kill()
end,
group = "client",
desc = "close",
},
qbind {
mods = qbind.mods.M,
triggers = "m",
press = function(c)
c.maximized = not c.maximized
end,
group = "client",
desc = "(un)maximize",
},
qbind {
mods = qbind.mods.M,
triggers = "n",
press = function(c)
gtimer.delayed_call(function()
c.minimized = true
end)
end,
group = "client",
desc = "minimize",
},
qbind {
mods = qbind.mods.M,
triggers = "f",
press = function(c)
c.fullscreen = not c.fullscreen
end,
group = "client",
desc = "toggle fullscreen",
},
}
end)
awful.keyboard.append_global_keybindings {
qbind {
mods = qbind.mods.MC,
triggers = "r",
press = awesome.restart,
group = "awesome",
desc = "restart awesome",
},
qbind {
mods = qbind.mods.M,
triggers = "F1",
press = function()
insightful:toggle()
end,
group = "awesome",
desc = "toggle insightful",
},
qbind {
mods = qbind.mods.M,
triggers = "space",
press = function()
fresnel:show()
end,
group = "awesome",
desc = "toggle fresnel",
},
qbind {
mods = qbind.mods.M,
triggers = "p",
press = function()
awful.screen.focused().bar:toggle()
end,
group = "awesome",
desc = "toggle bar panel",
},
qbind {
mods = qbind.mods.M,
triggers = "l",
press = function()
powermenu:toggle()
end,
group = "awesome",
desc = "toggle powermenu",
},
qbind {
triggers = "XF86AudioMute",
press = function()
awful.spawn "wpctl set-mute @DEFAULT_SINK@ toggle"
end,
group = "audio",
desc = "mute",
},
qbind {
triggers = {
{ "XF86AudioRaiseVolume", true },
{ "XF86AudioLowerVolume", false },
},
press = function(up)
if up then
-- awful.spawn "wpctl set-volume @DEFAULT_SINK@ 5%+"
print "up"
else
print "down"
-- awful.spawn "wpctl set-volume @DEFAULT_SINK@ 5%-"
end
end,
group = "audio",
desc = "increase/decrease volume",
},
qbind {
triggers = {
{ "XF86AudioNext", true },
{ "XF86AudioPrev", false },
},
press = function(next)
local active_player = playerctl:list()[mpris.active_player_index].instance
if next then
playerctl:next(active_player)
else
playerctl:previous(active_player)
end
end,
group = "audio",
desc = "previous/next song",
},
qbind {
triggers = "XF86AudioPlay",
press = function()
playerctl:play_pause(playerctl:list()[mpris.active_player_index].instance)
end,
group = "audio",
desc = "(un)pause song",
},
qbind {
mods = qbind.mods.M,
triggers = {
{ "Next", true },
{ "Prior", false },
},
press = function(next)
if next then
mpris.next_player()
else
mpris.previous_player()
end
end,
group = "audio",
desc = "previous/next player",
},
qbind {
triggers = {
{ "XF86MonBrightnessUp", true },
{ "XF86MonBrightnessDown", false },
},
press = function(up)
if up then
backlight.set(backlight.get() + 51)
else
backlight.set(backlight.get() - 51)
end
end,
group = "brightness",
desc = "increase/decrease brightness",
},
qbind {
mods = qbind.mods.M,
triggers = "Return",
press = function()
awful.spawn(cfg.terminal)
end,
group = "launcher",
desc = "launch terminal",
},
qbind {
triggers = "Print",
press = function()
local date = os.date "%Y%m%d_%H%M%S"
local path = os.getenv "HOME" .. "/Pictures/" .. date .. ".png"
-- Can't use naughty.notification cause it gets in the screenshot
-- Also can't use easy_async_with_shell cause it's buggy
awful.spawn.with_shell(
"maim --hidecursor "
.. path
.. " && xclip -selection clipboard -t image/png "
.. path
.. [[ && notify-send -a "Maim" "Screenshot taken" "Saved at ]]
.. path
.. [["]]
)
end,
group = "screenshot",
desc = "take fullscreen screenshot",
},
qbind {
mods = qbind.mods.S,
triggers = "Print",
press = function()
local date = os.date "%Y%m%d_%H%M%S"
local path = os.getenv "HOME" .. "/Pictures/" .. date .. ".png"
awful.spawn.with_shell(
"maim --hidecursor -s "
.. path
.. " && xclip -selection clipboard -t image/png "
.. path
.. [[ && notify-send -a "Maim" "Screenshot taken" "Saved at ]]
.. path
.. [["]]
)
end,
group = "screenshot",
desc = "take region screenshot",
},
qbind {
mods = qbind.mods.M,
triggers = "Print",
press = function()
if recording[1] then
awful.spawn "giph --stop"
naughty.notification {
app_name = "Giph",
title = "Recording stopped",
message = "Saved at " .. recording[2],
}
recording[1] = false
recording[2] = ""
else
recording[1] = true
recording[2] = os.getenv "HOME" .. "/Videos/" .. os.date "%Y%m%d_%H%M%S" .. ".mp4"
awful.spawn("giph --format mp4 --framerate 30 " .. recording[2])
naughty.notification {
app_name = "Giph",
title = "Recording started",
}
end
end,
group = "video",
desc = "toggle recording",
},
qbind {
mods = qbind.mods.M,
triggers = "k",
press = function()
awful.spawn "xkblayout-state set +1"
end,
group = "keyboard",
desc = "next keyboard layout",
},
qbind {
mods = qbind.mods.MS,
triggers = "k",
press = function()
awful.spawn "xkblayout-state set -1"
end,
group = "keyboard",
desc = "previous keyboard layout",
},
qbind {
mods = qbind.mods.M,
triggers = "Up",
press = awful.tag.viewprev,
group = "tag",
desc = "switch to previous",
},
qbind {
mods = qbind.mods.M,
triggers = "Down",
press = awful.tag.viewnext,
group = "tag",
desc = "switch to next",
},
qbind {
mods = qbind.mods.M,
triggers = gtable.join(awful.key.keygroups.numrow, awful.key.keygroups.numpad),
press = function(idx)
local tag = awful.screen.focused().tags[idx]
if not tag then
return
end
tag:view_only()
end,
group = "tag",
desc = "switch to the specified tag (if it exists)",
},
qbind {
mods = qbind.mods.MC,
triggers = "x",
press = function()
local tag = awful.screen.focused().selected_tag
tag.master_width_factor = cfg.tags[tonumber(tag.name)].master_width_factor or beautiful.master_width_factor
end,
group = "tag",
desc = "reset master width",
},
qbind {
mods = qbind.mods.M,
triggers = {
{ "XF86AudioRaiseVolume", true }, -- volume roller produces these events
{ "XF86AudioLowerVolume", false },
},
press = function(up)
awful.spawn("xdotool click " .. (up and "4" or "5"))
end,
group = "misc",
desc = "scroll up/down",
},
}
|