From 8abc0819df6f86f4de927d153652be2f118a817a Mon Sep 17 00:00:00 2001 From: crater2150 Date: Sun, 1 Mar 2015 21:34:50 +0100 Subject: [PATCH] Bindings: change API to make bindings module responsible for all bindings --- bindings.lua | 13 +++++++++++-- rc.lua | 8 +++----- tags.lua | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/bindings.lua b/bindings.lua index 7ffc8ba..9b9381f 100644 --- a/bindings.lua +++ b/bindings.lua @@ -9,6 +9,8 @@ local modkey = conf.modkey or "Mod4" local mb = require("modalbind") local calendar = require("calendar") +local globalkeys = {} + app_folders = { "/usr/share/applications", "/usr/local/share/applications", @@ -90,8 +92,8 @@ layoutsettings = { C = { func = function () awful.tag.incncol(-1) end, desc = "Less columns" }, } -function bindings.extend_key_table(globalkeys) - return awful.util.table.join(globalkeys or {}, +function bindings.setup() + globalkeys = awful.util.table.join( awful.key({ }, "Pause", spawnf('wmselect')), -- old keyboard awful.key({ }, "Print", spawnf('wmselect')), -- new keyboard @@ -203,6 +205,13 @@ function bindings.extend_key_table(globalkeys) --}}} 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) if c.opacity < 0 or c.opacity > 1 then diff --git a/rc.lua b/rc.lua index 07acd2d..cfae880 100644 --- a/rc.lua +++ b/rc.lua @@ -57,14 +57,12 @@ end -- }}} -- {{{ Key bindings -globalkeys = {} -globalkeys = tags.extend_key_table(globalkeys); bindings = require("bindings") +bindings.setup() bindings.modalbind.set_x_offset(18) -globalkeys = bindings.extend_key_table(globalkeys) - -root.keys(globalkeys) +bindings.add_bindings(tags.create_bindings()) +bindings.apply() -- }}} -- {{{ rules diff --git a/tags.lua b/tags.lua index be0eab5..3e97fd0 100644 --- a/tags.lua +++ b/tags.lua @@ -84,14 +84,14 @@ function tags.setup(setuptable) end end -function tags.extend_key_table(globalkeys) +function tags.create_bindings() -- Compute the maximum number of digit we need, limited to 22 keynumber = 0 for s = 1, screen.count() do keynumber = math.min(22, math.max(#(list[s]), keynumber)); end - local tagkeys = globalkeys or {} + local tagkeys = {} -- Bind all key numbers to tags, using keycodes for i = 1, keynumber do