89 function quit() |
89 function quit() |
90 kill_all(function (c) return true end) |
90 kill_all(function (c) return true end) |
91 awesome.quit() |
91 awesome.quit() |
92 end |
92 end |
93 |
93 |
94 function show_clients() |
|
95 if instance then |
|
96 instance:hide() |
|
97 instance = nil |
|
98 else |
|
99 instance = awful.menu.clients({width=250}) |
|
100 end |
|
101 end |
|
102 |
|
103 local function widgets_cpu() |
94 local function widgets_cpu() |
104 local w = awful.widget.graph() |
95 local w = awful.widget.graph() |
105 -- Graph properties |
96 -- Graph properties |
106 w:set_width(30) |
97 w:set_width(30) |
107 w:set_background_color(beautiful.bg_normal) |
98 w:set_background_color(beautiful.bg_normal) |
183 mode = widgets_mode, |
174 mode = widgets_mode, |
184 keyboard = widgets_keyboard, |
175 keyboard = widgets_keyboard, |
185 decorated = widgets_decorated, |
176 decorated = widgets_decorated, |
186 |
177 |
187 } |
178 } |
|
179 |
|
180 function split_modifiers(key) |
|
181 local modifiers = {} |
|
182 local pattern = capi.string.format("([^+]+)", sep) |
|
183 key:gsub(pattern, function(mod) table.insert(modifiers, mod) end) |
|
184 key = table.remove(modifiers) |
|
185 return modifiers, key |
|
186 end |
|
187 |
|
188 function normalize_key(k) |
|
189 mods, key = split_modifiers(k) |
|
190 if #mods > 0 then |
|
191 table.sort(mods) |
|
192 k = table.concat(mods, "+") .. "+" .. key |
|
193 end |
|
194 return k |
|
195 end |
|
196 |
188 function make_key(k, n, f) |
197 function make_key(k, n, f) |
|
198 k = normalize_key(k) |
189 return { key = k, name = n, func = f} |
199 return { key = k, name = n, func = f} |
190 end |
200 end |
191 |
201 |
192 function make_single_key(k, n, f) |
202 function make_single_key(k, n, f) |
193 if f == nil then |
203 if f == nil then |
194 log("name: " .. n .. " is nil", 3) |
204 log("name: " .. n .. " is nil", 3) |
195 end |
205 end |
196 return make_key(k, n, function (c) f(c); return true ; end) |
206 return make_key(k, n, function (c) f(c); return false ; end) |
|
207 end |
|
208 |
|
209 function make_interactive_key(k, n, f) |
|
210 return make_key(k, n, function (c) f(c); return true; end) |
197 end |
211 end |
198 |
212 |
199 function show_kt(keytable, title) |
213 function show_kt(keytable, title) |
200 -- todo: replace with a menu ? |
214 -- todo: replace with a menu ? |
201 text = "" |
215 text = "" |
223 if not ignored_mods[v] then |
237 if not ignored_mods[v] then |
224 skey = skey .. v .. "+" |
238 skey = skey .. v .. "+" |
225 end |
239 end |
226 end |
240 end |
227 skey = skey .. (keynames[key] or key) |
241 skey = skey .. (keynames[key] or key) |
228 return skey |
242 return normalize_key(skey) |
229 end |
243 end |
230 |
244 |
231 local function kt_handler(keytable, mod, key, event) |
245 local function kt_handler(keytable, mod, key, event) |
232 if event == "release" then |
246 if event == "release" then |
233 return true |
247 return true |
235 widgets.mode_widget_bg:set_bg(beautiful.bg_focus) |
249 widgets.mode_widget_bg:set_bg(beautiful.bg_focus) |
236 if key == "Escape" then |
250 if key == "Escape" then |
237 return false |
251 return false |
238 end |
252 end |
239 local skey = capi.string.lower(translate_key(mod, key)) |
253 local skey = capi.string.lower(translate_key(mod, key)) |
240 if skey == "control+h" or skey == "shift+?" then |
254 if skey == "control+h" or skey == "shift+?" or skey == "f1" then |
241 show_kt(keytable, "Current binding") |
255 show_kt(keytable, "Current binding") |
242 return true |
256 return true |
243 end |
257 end |
244 for _,k in ipairs(keytable) do |
258 for _,k in ipairs(keytable) do |
245 if skey == capi.string.lower(k.key) then |
259 if skey == capi.string.lower(k.key) then |
298 awful.client.focus.bydirection(direction) |
312 awful.client.focus.bydirection(direction) |
299 if capi.client.focus then capi.client.focus:raise() end |
313 if capi.client.focus then capi.client.focus:raise() end |
300 return true |
314 return true |
301 end |
315 end |
302 end |
316 end |
303 |
|
304 function split_modifiers(key) |
|
305 local modifiers = {} |
|
306 local pattern = capi.string.format("([^+]+)", sep) |
|
307 key:gsub(pattern, function(mod) table.insert(modifiers, mod) end) |
|
308 key = table.remove(modifiers) |
|
309 return modifiers, key |
|
310 end |
|
311 |
317 |
312 function make_globalkeys(modifiers, keytable) |
318 function make_globalkeys(modifiers, keytable) |
313 local t = {} |
319 local t = {} |
314 for _,k in ipairs(keytable) do |
320 for _,k in ipairs(keytable) do |
315 local mods, key = split_modifiers(k.key) |
321 local mods, key = split_modifiers(k.key) |