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
|
local M = {}
local awful = require("awful")
local gears = require("gears")
local commondefs = require("commondefs")
local utils = require("utils")
function M.create(workspace)
local modkey = commondefs.modkey
local globalkeys = gears.table.join(
awful.key({ modkey, "Mod1" }, "Delete", awesome.restart),
awful.key({ modkey }, "Pause", function () awful.spawn("xscreensaver-command -lock") end),
awful.key({ modkey }, "XF86ScreenSaver", function () awful.spawn("xscreensaver-command -lock") end),
-- something of a hack: diziet is configured to send F13/XF86Tools on lid close
-- this should trigger a screen lock if HDMI cable is not connected
awful.key({ }, "XF86Tools",
function ()
awful.spawn.with_shell("cat /sys/class/drm/card0/*HDMI*/status|grep -q '^connected' || xscreensaver-command -suspend")
end),
awful.key({ }, "XF86Launch5",
function ()
awful.spawn.with_shell("xscreensaver-command -deactivate")
end),
-- program launching
awful.key({ modkey, }, "t", function () utils.spawn_current(commondefs.terminal) end),
awful.key({ modkey, }, "v", function () utils.spawn_current(commondefs.terminal .. " -e alsamixer") end),
awful.key({ modkey, }, "Escape", function () utils.spawn_current(commondefs.terminal .. " -e htop") end),
-- audio control
awful.key({ modkey }, "Prior", function () utils.vol_control(1) end),
awful.key({ modkey }, "Next", function () utils.vol_control(-1) end),
awful.key({ modkey }, "grave", function () awful.spawn("mpc toggle") end),
awful.key({ modkey }, "b", function () awful.spawn("mpc next") end),
awful.key({ modkey }, "p", function () awful.spawn("mpc prev") end),
-- focus/screen switching
awful.key({ modkey, }, "q", function() utils.screen_focus_physical(1) end),
awful.key({ modkey, }, "w", function() utils.screen_focus_physical(2) end),
awful.key({ modkey, }, "e", function() utils.screen_focus_physical(3) end),
awful.key({ modkey, }, "Up", function() workspace:view_relative(-1) end ),
awful.key({ modkey, }, "Down", function() workspace:view_relative(1) end ),
awful.key({ modkey, }, "k", function() workspace:view_relative(-1) end ),
awful.key({ modkey, }, "j", function() workspace:view_relative(1) end ),
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, "Shift" }, "Tab",
function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, "Mod1" }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
-- Layout manipulation
awful.key({ modkey, }, "Return",
function()
if client.focus then
awful.client.setmaster(client.focus)
end
end),
awful.key({ modkey, "Shift" }, "h", function () awful.client.swap.byidx( 1) end),
awful.key({ modkey, "Shift" }, "l", function () awful.client.swap.byidx( -1) end),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, }, ",", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, }, ".", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
-- move to upper/lower page
awful.key({ modkey, "Shift" }, "j",
function ()
if client.focus then
local c = client.focus
workspace:client_move_relative(c, 1)
end
end),
awful.key({ modkey, "Shift" }, "k",
function ()
if client.focus then
local c = client.focus
workspace:client_move_relative(c, -1)
end
end),
-- swap two screens
awful.key({ modkey, "Mod1" }, "q",
function ()
local screen_dst = mouse.screen
local screen_src = utils.screen_physical(1)
if screen_src ~= screen_dst then
local desk_idx = workspace.screen_state[screen_src].desktop_idx
local page_idx = workspace.screen_state[screen_src].page_idx
workspace:view(screen_dst, desk_idx, page_idx)
end
end),
awful.key({ modkey, "Mod1" }, "w",
function ()
local screen_dst = mouse.screen
local screen_src = utils.screen_physical(2)
if screen_src ~= screen_dst then
local desk_idx = workspace.screen_state[screen_src].desktop_idx
local page_idx = workspace.screen_state[screen_src].page_idx
workspace:view(screen_dst, desk_idx, page_idx)
end
end),
awful.key({ modkey, "Mod1" }, "e",
function ()
local screen_dst = mouse.screen
local screen_src = utils.screen_physical(3)
if screen_src ~= screen_dst then
local desk_idx = workspace.screen_state[screen_src].desktop_idx
local page_idx = workspace.screen_state[screen_src].page_idx
workspace:view(screen_dst, desk_idx, page_idx)
end
end),
-- Prompt
awful.key({ modkey }, "n",
function()
awful.prompt.run({ prompt = "Rename desktop: " },
mypromptbox[mouse.screen].widget,
function(input)
if input then
local cur_desk = workspace.screen_state[mouse.screen].desktop_idx
workspace:rename_desktop(cur_desk, input)
end
end)
end)
)
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 10 do
globalkeys = gears.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
local state = workspace.screen_state[screen]
local desk = 1
if state then
desk = state.desktop_idx
end
workspace:view(screen, desk, i)
end),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local c = client.focus
workspace:move_client(c, workspace.screen_state[c.screen].desktop_idx, i)
end
end))
end
for i = 1, 12 do
globalkeys = gears.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 66,
function ()
local screen = mouse.screen
workspace:view(screen, i)
end),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local c = client.focus
workspace:move_client(c, workspace.screen_state[c.screen].desktop_idx, i)
end
end))
end
local clientkeys = gears.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end),
awful.key({ modkey, "Shift" }, "q", function( c) c:move_to_screen(utils.screen_physical(1)) end),
awful.key({ modkey, "Shift" }, "w", function( c) c:move_to_screen(utils.screen_physical(2)) end),
awful.key({ modkey, "Shift" }, "e", function( c) c:move_to_screen(utils.screen_physical(3)) end),
awful.key({ modkey, }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
c.maximized = not c.maximized
end),
awful.key({ modkey, "Shift" }, "m",
function (c)
c.maximized_horizontal = false
c.maximized_vertical = false
c.maximized = false
end),
awful.key({ modkey, "Control" }, "m",
function (c)
c.maximized_horizontal = true
c.maximized_vertical = true
c.maximized = true
end)
)
return globalkeys, clientkeys
end
return M
|