From 31e2a19f65992a591c92a3b00ca9793ac22e0327 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 18 Jun 2016 01:03:53 -0400 Subject: [PATCH 1/2] key: Make the ignore_modifiers table public The prompt need to re-use it and Mod2 could be useful to toggle between 2 different Awesome modes. --- lib/awful/key.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/awful/key.lua b/lib/awful/key.lua index 834f7198f..7a73bb2ce 100644 --- a/lib/awful/key.lua +++ b/lib/awful/key.lua @@ -22,9 +22,9 @@ local key = { mt = {}, hotkeys = {} } -- By default this is initialized as { "Lock", "Mod2" } -- so the Caps Lock or Num Lock modifier are not taking into account by awesome -- when pressing keys. --- @name ignore_modifiers +-- @name awful.key.ignore_modifiers -- @class table -local ignore_modifiers = { "Lock", "Mod2" } +key.ignore_modifiers = { "Lock", "Mod2" } --- Convert the modifiers into pc105 key names local conversion = { @@ -83,7 +83,7 @@ function key.new(mod, _key, press, release, data) release=nil end local ret = {} - local subsets = util.subsets(ignore_modifiers) + local subsets = util.subsets(key.ignore_modifiers) for _, set in ipairs(subsets) do ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set), key = _key }) From a87d75246f0e3b0c9c9cf538a7f04280f2727f6b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 19 Jun 2016 00:23:46 -0400 Subject: [PATCH 2/2] prompt: Fix hooks when number or caps lock are set --- lib/awful/prompt.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/awful/prompt.lua b/lib/awful/prompt.lua index 549d77266..4dcfe7df6 100644 --- a/lib/awful/prompt.lua +++ b/lib/awful/prompt.lua @@ -22,6 +22,7 @@ local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility local keygrabber = require("awful.keygrabber") local util = require("awful.util") local beautiful = require("beautiful") +local akey = require("awful.key") local prompt = {} @@ -360,15 +361,24 @@ function prompt.run(args, textbox, exe_callback, completion_callback, end end + local filtered_modifiers = {} + -- User defined cases if hooks[key] then + -- Remove caps and num lock + for _, m in ipairs(modifiers) do + if not util.table.hasitem(akey.ignore_modifiers, m) then + table.insert(filtered_modifiers, m) + end + end + for _,v in ipairs(hooks[key]) do - if #modifiers == #v[1] then + if #filtered_modifiers == #v[1] then local match = true for _,v2 in ipairs(v[1]) do match = match and mod[v2] end - if match or #modifiers == 0 then + if match or #filtered_modifiers == 0 then local cb local ret = v[3](command) if ret then