Bindings: change API to make bindings module responsible for all bindings

This commit is contained in:
crater2150 2015-03-01 21:34:50 +01:00
parent 6a5115bc7b
commit 8abc0819df
3 changed files with 16 additions and 9 deletions

View file

@ -9,6 +9,8 @@ local modkey = conf.modkey or "Mod4"
local mb = require("modalbind") local mb = require("modalbind")
local calendar = require("calendar") local calendar = require("calendar")
local globalkeys = {}
app_folders = { app_folders = {
"/usr/share/applications", "/usr/share/applications",
"/usr/local/share/applications", "/usr/local/share/applications",
@ -90,8 +92,8 @@ layoutsettings = {
C = { func = function () awful.tag.incncol(-1) end, desc = "Less columns" }, C = { func = function () awful.tag.incncol(-1) end, desc = "Less columns" },
} }
function bindings.extend_key_table(globalkeys) function bindings.setup()
return awful.util.table.join(globalkeys or {}, globalkeys = awful.util.table.join(
awful.key({ }, "Pause", spawnf('wmselect')), -- old keyboard awful.key({ }, "Pause", spawnf('wmselect')), -- old keyboard
awful.key({ }, "Print", spawnf('wmselect')), -- new keyboard awful.key({ }, "Print", spawnf('wmselect')), -- new keyboard
@ -203,6 +205,13 @@ function bindings.extend_key_table(globalkeys)
--}}} --}}}
end end
function bindings.add_bindings(keys)
globalkeys = awful.util.table.join(globalkeys, keys);
end
function bindings.apply()
root.keys(globalkeys)
end
local function client_opacity_set(c, default, max, step) local function client_opacity_set(c, default, max, step)
if c.opacity < 0 or c.opacity > 1 then if c.opacity < 0 or c.opacity > 1 then

8
rc.lua
View file

@ -57,14 +57,12 @@ end
-- }}} -- }}}
-- {{{ Key bindings -- {{{ Key bindings
globalkeys = {}
globalkeys = tags.extend_key_table(globalkeys);
bindings = require("bindings") bindings = require("bindings")
bindings.setup()
bindings.modalbind.set_x_offset(18) bindings.modalbind.set_x_offset(18)
globalkeys = bindings.extend_key_table(globalkeys) bindings.add_bindings(tags.create_bindings())
bindings.apply()
root.keys(globalkeys)
-- }}} -- }}}
-- {{{ rules -- {{{ rules

View file

@ -84,14 +84,14 @@ function tags.setup(setuptable)
end end
end end
function tags.extend_key_table(globalkeys) function tags.create_bindings()
-- Compute the maximum number of digit we need, limited to 22 -- Compute the maximum number of digit we need, limited to 22
keynumber = 0 keynumber = 0
for s = 1, screen.count() do for s = 1, screen.count() do
keynumber = math.min(22, math.max(#(list[s]), keynumber)); keynumber = math.min(22, math.max(#(list[s]), keynumber));
end end
local tagkeys = globalkeys or {} local tagkeys = {}
-- Bind all key numbers to tags, using keycodes -- Bind all key numbers to tags, using keycodes
for i = 1, keynumber do for i = 1, keynumber do