-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeys.lua
582 lines (532 loc) · 17.3 KB
/
keys.lua
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
-- ░█░█░█▀▀░█░█░█▀▄░▀█▀░█▀█░█▀▄░█▀▀
-- ░█▀▄░█▀▀░░█░░█▀▄░░█░░█░█░█░█░▀▀█
-- ░▀░▀░▀▀▀░░▀░░▀▀░░▀▀▀░▀░▀░▀▀░░▀▀▀
local gears = require("gears")
local beautiful = require("beautiful")
local awful = require("awful")
local hotkeys_popup = require("awful.hotkeys_popup")
local helpers = require("helpers")
local awesome = awesome
local client = client
local root = root
local keys = {}
local mod = "Mod4"
local alt = "Mod1"
local ctrl = "Control"
local shift = "Shift"
-- Menu
-- =============================================
local menu = {}
menu.awesome = {
{
"Hotkeys",
function()
hotkeys_popup.show_help(nil, awful.screen.focused())
end,
},
{
"Manual",
function()
awful.spawn(user.terminal .. " -e man awesome")
end,
},
{
"Edit config",
function()
awful.spawn(user.editor .. " " .. awesome.conffile)
end,
},
{
"Restart",
function()
awesome.restart()
end,
},
{
"Quit",
function()
awesome.quit()
end,
},
}
menu.mainmenu = awful.menu({
items = {
{ " Terminal", user.terminal },
{ " Explorer", apps.file_manager },
{ " Browser", apps.browser },
{ " Editor", apps.editor },
{ " GUI Editor", apps.visual_editor },
{ " AwesomeWM", menu.awesome },
{
" Notifications",
function()
awesome.emit_signal("summon::notif_center")
end,
},
},
})
-- Mouse bindings on desktop
-- =============================================
keys.desktopbuttons = gears.table.join(
awful.button({}, 1, function()
-- Single tap
awesome.emit_signal("summon::dismiss")
if menu.mainmenu then
menu.mainmenu:hide()
end
-- if sidebar_hide then
-- sidebar_hide()
-- end
end),
-- Right click - Show app drawer
awful.button({}, 3, function()
menu.mainmenu:toggle()
end),
-- Middle button - Toggle dashboard
-- awful.button({ }, 2, function()
-- if dashboard_show then
-- dashboard_show()
-- end
-- end),
-- Scrolling - Switch tags
-- awful.button({ }, 4, awful.tag.viewprev),
-- awful.button({ }, 5, awful.tag.viewnext),
-- Side buttons - Control volume
awful.button({}, 8, function()
helpers.volume_control(-5)
end),
awful.button({}, 9, function()
helpers.volume_control(5)
end)
-- Side buttons - Minimize and restore minimized client
-- awful.button({}, 8, function()
-- if client.focus ~= nil then
-- client.focus.minimized = true
-- end
-- end),
-- awful.button({}, 9, function()
-- local c = awful.client.restore()
-- -- Focus restored client
-- if c then
-- client.focus = c
-- end
-- end)
)
-- Global bindings
-- =============================================
keys.globalkeys = gears.table.join(
awful.key({
modifiers = { mod },
keygroup = "numrow",
description = "only view tag",
group = "tag",
on_press = function(index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end,
}),
awful.key({
modifiers = { mod, ctrl },
keygroup = "numrow",
description = "toggle tag",
group = "tag",
on_press = function(index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
awful.tag.viewtoggle(tag)
end
end,
}),
awful.key({
modifiers = { mod, shift },
keygroup = "numrow",
description = "move focused client to tag",
group = "tag",
on_press = function(index)
if client.focus then
local tag = client.focus.screen.tags[index]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
}),
awful.key({ mod }, "space", function()
awful.layout.inc(1)
end, { description = "next layout", group = "tag" }),
awful.key({ mod, shift }, "space", function()
awful.layout.inc(-1)
end, { description = "previous layout", group = "tag" }),
-- Tag switcher
awful.key({ mod }, "Tab", function()
awful.tag.viewnext()
end, { description = "next tag", group = "client" }),
awful.key({ mod, shift }, "Tab", function()
awful.tag.viewprev()
end, { description = "prev tag", group = "client" }),
-- Focus client by direction (hjkl keys)
awful.key({ mod }, "j", function()
awful.client.focus.bydirection("down")
end, { description = "focus down", group = "client" }),
awful.key({ mod }, "k", function()
awful.client.focus.bydirection("up")
end, { description = "focus up", group = "client" }),
awful.key({ mod }, "h", function()
awful.client.focus.bydirection("left")
end, { description = "focus left", group = "client" }),
awful.key({ mod }, "l", function()
awful.client.focus.bydirection("right")
end, { description = "focus right", group = "client" }),
-- Focus client by index (cycle through clients)
awful.key({ mod }, "z", function()
awful.client.focus.byidx(1)
end, { description = "focus next by index", group = "client" }),
awful.key({ mod, shift }, "z", function()
awful.client.focus.byidx(-1)
end, { description = "focus next by index", group = "client" }),
-- Focus client by direction (arrow keys)
awful.key({ mod }, "Down", function()
awful.client.focus.bydirection("down")
end, { description = "focus down", group = "client" }),
awful.key({ mod }, "Up", function()
awful.client.focus.bydirection("up")
end, { description = "focus up", group = "client" }),
awful.key({ mod }, "Left", function()
awful.client.focus.bydirection("left")
end, { description = "focus left", group = "client" }),
awful.key({ mod }, "Right", function()
awful.client.focus.bydirection("right")
end, { description = "focus right", group = "client" }),
-- Urgent or Undo:
-- Jump to urgent client or (if there is no such client) go back
-- to the last tag
awful.key({ mod }, "u", function()
uc = awful.client.urgent.get()
-- If there is no urgent client, go back to last tag
if uc == nil then
awful.tag.history.restore()
else
awful.client.urgent.jumpto()
end
end, { description = "jump to urgent client", group = "client" }),
awful.key({ mod }, "x", function()
awful.tag.history.restore()
end, { description = "go back", group = "tag" }),
-- Spawn terminal
awful.key({ mod }, "Return", function()
awful.spawn(user.terminal)
end, { description = "open a terminal", group = "launcher" }),
-- Spawn floating terminal
awful.key({ mod, shift }, "Return", function()
awful.spawn(user.floating_terminal, { floating = true })
end, { description = "spawn floating terminal", group = "launcher" }),
-- Reload Awesome
awful.key({ mod, shift }, "r", function()
awesome.restart()
end, { description = "reload awesome", group = "awesome" }),
-- Quit Awesome
awful.key({ mod, shift }, "q", function()
awesome.quit()
end, { description = "quit awesome", group = "awesome" }),
awful.key({ mod, shift }, "x", function()
awesome.quit()
-- exit_screen_show()
end, { description = "quit awesome", group = "awesome" }),
awful.key({}, "XF86PowerOff", function()
awesome.quit()
-- exit_screen_show()
end, { description = "quit awesome", group = "awesome" }),
-- Resize focused client or layout factor
awful.key({ mod, ctrl }, "Down", function(c)
helpers.resize_dwim(client.focus, "down")
end),
awful.key({ mod, ctrl }, "Up", function(c)
helpers.resize_dwim(client.focus, "up")
end),
awful.key({ mod, ctrl }, "Left", function(c)
helpers.resize_dwim(client.focus, "left")
end),
awful.key({ mod, ctrl }, "Right", function(c)
helpers.resize_dwim(client.focus, "right")
end),
awful.key({ mod, ctrl }, "j", function(c)
helpers.resize_dwim(client.focus, "down")
end),
awful.key({ mod, ctrl }, "k", function(c)
helpers.resize_dwim(client.focus, "up")
end),
awful.key({ mod, ctrl }, "h", function(c)
helpers.resize_dwim(client.focus, "left")
end),
awful.key({ mod, ctrl }, "l", function(c)
helpers.resize_dwim(client.focus, "right")
end),
-- Focus restored client
awful.key({ mod, shift }, "n", function()
local c = awful.client.restore()
if c then
client.focus = c
end
end, { description = "restore minimized", group = "client" }),
-- Dismiss notifications and elements that connect to the dismiss signal
awful.key({ ctrl }, "space", function()
awesome.emit_signal("summon::dismiss")
end, { description = "dismiss notification", group = "notifications" }),
-- Scratchpad terminal
awful.key({ mod }, "s", function()
helpers.scratchpad({ instance = "scratchpad" }, user.scratchpad_terminal, nil)
end, { description = "scratchpad", group = "launcher" }),
-- Screen Shots/Vids
awful.key({}, "Print", apps.screenshot_full, { description = "screenshot gui", group = "awesome" }),
awful.key(
{ shift },
"Print",
apps.screenshot_clipboard,
{ description = "screenshot to clipboard", group = "awesome" }
),
-- Prompt
awful.key({ mod }, "d", function()
awful.screen.focused().mypromptbox:run()
end, { description = "run prompt", group = "launcher" }),
--- App launcher
awful.key({ mod }, "a", function()
awful.spawn(user.app_launcher)
end, { description = "app launcher", group = "app" }),
--- Emoji picker
awful.key({ mod }, "e", apps.emoji_picker, { description = "emoji picker", group = "app" }),
--- Clipboard
awful.key({ mod }, "v", apps.clipboard, { description = "clipboard", group = "app" }),
-- Hotkeys list
awful.key({ mod }, "F1", function()
hotkeys_popup.show_help()
end, { description = "show help", group = "awesome" }),
-- Volume control with volume keys
awful.key({}, "XF86AudioMute", function()
helpers.volume_control(0)
end, { description = "(un)mute volume", group = "volume" }),
awful.key({}, "XF86AudioLowerVolume", function()
helpers.volume_control(-5)
awesome.emit_signal("summon::osd")
end, { description = "lower volume", group = "volume" }),
awful.key({}, "XF86AudioRaiseVolume", function()
helpers.volume_control(5)
awesome.emit_signal("summon::osd")
end, { description = "raise volume", group = "volume" }),
-- Brightness control with brightness keys
awful.key({}, "XF86MonBrightnessUp", function()
awful.spawn("light -A 10")
awesome.emit_signal("summon::osd")
end, { description = "increase brightness", group = "brightness" }),
awful.key({}, "XF86MonBrightnessDown", function()
awful.spawn("light -U 10")
awesome.emit_signal("summon::osd")
end, { description = "decrease brightness", group = "brightness" }),
-- Music
awful.key({}, "XF86AudioPlay", function()
awful.spawn.with_shell("playerctl play-pause")
end, { description = "play pause music", group = "volume" }),
awful.key({}, "XF86AudioPrev", function()
awful.spawn.with_shell("playerctl previous")
end, { description = "previous music", group = "volume" }),
awful.key({}, "XF86AudioNext", function()
awful.spawn.with_shell("playerctl next")
end, { description = "next music", group = "volume" }),
-- Lockscreen
awful.key({ mod, alt }, "l", function()
awesome.emit_signal("summon::lock_screen")
end, { description = "lock screen", group = "hotkeys" }),
-- Apps
-- Spawn browser
awful.key({ mod }, "F2", apps.browser, { description = "web browser", group = "launcher" }),
-- Spawn gui file manager
awful.key({ mod }, "F3", apps.file_manager, { description = "file manager", group = "launcher" }),
-- Terminal file manager
awful.key({ mod }, "F4", apps.term_filemanager, { description = "term filemanager", group = "launcher" }),
-- Primary editor
awful.key({ mod }, "F5", apps.editor, { description = "editor", group = "launcher" }),
-- Gui editor
awful.key({ mod }, "F6", apps.visual_editor, { description = "visual editor", group = "launcher" }),
-- Add more
awful.key({ mod }, "F7", apps.file_manager, { description = "file manager", group = "launcher" }),
awful.key({ mod }, "F8", apps.file_manager, { description = "file manager", group = "launcher" }),
awful.key({ mod }, "F9", apps.file_manager, { description = "file manager", group = "launcher" }),
awful.key({ mod }, "F10", apps.file_manager, { description = "file manager", group = "launcher" }),
-- Volume control
awful.key({ mod }, "F11", apps.volume, { description = "volume control", group = "launcher" }),
-- Process monitor
awful.key({ mod }, "F12", apps.process_monitor, { description = "process monitor", group = "launcher" })
)
-- Client related bindings
-- =============================================
keys.clientkeys = gears.table.join(
-- Swap by direction
awful.key({ mod, shift }, "j", function()
awful.client.swap.bydirection("down")
end),
awful.key({ mod, shift }, "k", function()
awful.client.swap.bydirection("up")
end),
awful.key({ mod, shift }, "h", function()
awful.client.swap.bydirection("left")
end),
awful.key({ mod, shift }, "l", function()
awful.client.swap.bydirection("right")
end),
-- Toggle fullscreen
awful.key({ mod }, "f", function(c)
c.fullscreen = not c.fullscreen
c:raise()
end, { description = "toggle fullscreen", group = "client" }),
-- Close client
awful.key({ mod }, "q", function(c)
c:kill()
end, { description = "close", group = "client" }),
awful.key({ alt }, "F4", function(c)
c:kill()
end, { description = "close", group = "client" }),
--- Center client
awful.key({ mod }, "c", function()
awful.placement.centered(c, { honor_workarea = true, honor_padding = true })
end),
-- Switch clients
awful.key({ alt }, "Tab", function()
awesome.emit_signal("window_switcher::turn_on")
-- awful.client.focus.byidx(1)
end, { description = "focus next by index", group = "client" }),
-- Toggle floating
awful.key({ mod, ctrl }, "space", function(c)
local layout_is_floating = (awful.layout.get(mouse.screen) == awful.layout.suit.floating)
if not layout_is_floating then
awful.client.floating.toggle()
end
end, { description = "toggle floating", group = "client" }),
-- Set master
awful.key({ mod, ctrl }, "Return", function(c)
c:swap(awful.client.getmaster())
end, { description = "move to master", group = "client" }),
-- P for pin: keep on top OR sticky
-- On top
awful.key({ mod, shift }, "p", function(c)
c.ontop = not c.ontop
end, { description = "toggle keep on top", group = "client" }),
-- Sticky
awful.key({ mod, ctrl }, "p", function(c)
c.sticky = not c.sticky
end, { description = "toggle sticky", group = "client" }),
-- Minimize
awful.key({ mod }, "n", function(c)
c.minimized = true
end, { description = "minimize", group = "client" }),
-- Maximize
awful.key({ mod }, "m", function(c)
c.maximized = not c.maximized
end, { description = "(un)maximize", group = "client" }),
awful.key({ mod, ctrl }, "m", function(c)
c.maximized_vertical = not c.maximized_vertical
c:raise()
end, { description = "(un)maximize vertically", group = "client" }),
awful.key({ mod, shift }, "m", function(c)
c.maximized_horizontal = not c.maximized_horizontal
c:raise()
end, { description = "(un)maximize horizontally", group = "client" })
)
-- Mouse buttons on the client (whole window, not just titlebar)
-- =============================================
keys.clientbuttons = gears.table.join(
awful.button({}, 1, function(c)
client.focus = c
end),
awful.button({ mod }, 1, awful.mouse.client.move),
-- awful.button({ mod }, 2, function(c) c:kill() end),
awful.button({ mod }, 3, function(c)
client.focus = c
awful.mouse.client.resize(c)
-- awful.mouse.resize(c, nil, {jump_to_corner=true})
end)
-- Super + scroll = Change client opacity
-- awful.button({ mod }, 4, function(c)
-- c.opacity = c.opacity + 0.1
-- end),
-- awful.button({ mod }, 5, function(c)
-- c.opacity = c.opacity - 0.1
-- end)
)
-- Mouse buttons on the tasklist
-- Use 'Any' modifier so that the same buttons can be used in the floating
-- tasklist displayed by the window switcher while the mod is pressed
-- =============================================
keys.tasklist_buttons = gears.table.join(
awful.button({ "Any" }, 1, function(c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
end
end),
-- Middle mouse button closes the window (on release)
awful.button({ "Any" }, 2, nil, function(c)
c:kill()
end),
awful.button({ "Any" }, 3, function(c)
c.minimized = true
end),
awful.button({ "Any" }, 4, function()
awful.client.focus.byidx(-1)
end),
awful.button({ "Any" }, 5, function()
awful.client.focus.byidx(1)
end),
-- Side button up - toggle floating
awful.button({ "Any" }, 9, function(c)
c.floating = not c.floating
end),
-- Side button down - toggle ontop
awful.button({ "Any" }, 8, function(c)
c.ontop = not c.ontop
end)
)
-- Mouse buttons on a tag of the taglist widget
-- =============================================
keys.taglist_buttons = gears.table.join(
awful.button({}, 1, function(t)
t:view_only()
end),
awful.button({ mod }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
-- awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({}, 3, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ mod }, 3, function(t)
if client.focus then
client.focus:toggle_tag(t)
end
end),
awful.button({}, 4, function(t)
awful.tag.viewprev(t.screen)
end),
awful.button({}, 5, function(t)
awful.tag.viewnext(t.screen)
end)
)
root.keys(keys.globalkeys)
root.buttons(keys.desktopbuttons)
return keys
-- EOF ------------------------------------------------------------------------