From e97eeff187c208a3d5474f3ff5b036d30c52e415 Mon Sep 17 00:00:00 2001 From: ArenaL5 Date: Sun, 22 Mar 2020 01:11:55 +0100 Subject: [PATCH 1/2] Label numeric keypad Enter to hotkeys_popup When adding human-readable key names to `lib/awful/hotkeys_popup/widget.lua`, I forgot to add the Enter key in the numeric keypad to the list. Signed-off-by: ArenaL5 --- lib/awful/hotkeys_popup/widget.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/awful/hotkeys_popup/widget.lua b/lib/awful/hotkeys_popup/widget.lua index e8957e3f1..0157cd33f 100644 --- a/lib/awful/hotkeys_popup/widget.lua +++ b/lib/awful/hotkeys_popup/widget.lua @@ -218,6 +218,7 @@ function widget.new(args) KP_Multiply = "Num*", KP_Subtract = "Num-", KP_Add = "Num+", + KP_Enter = "NumEnter", -- Some "obvious" entries are necessary for the Escape sequence -- and whitespace characters: Escape = "Esc", From 15929b0797f396ff2ba88b97d9dc87e6a2dc1c7c Mon Sep 17 00:00:00 2001 From: ArenaL5 Date: Sun, 22 Mar 2020 01:13:37 +0100 Subject: [PATCH 2/2] Add F-keys and numpad to `awful.key.keygroups` Signed-off-by: ArenaL5 Extend `fkeys` to F35 Signed-off-by: ArenaL5 Reducing `numpad` to its most aggreable subset Signed-off-by: ArenaL5 Add method to select a layout directly using the Super key + the numeric keypad. This method uses the layout list from the currently selected tag in the currently focused screen. (If there is no selected tag, it does nothing.) To allow this, the keygroups `numpad` and `fkeys` were added to `awful.key.keygroups`. Refit to avoid error by nil and to remove imperative code, as per recommendation from @Elv13. Signed-off-by: ArenaL5 --- awesomerc.lua | 12 ++++++++++++ lib/awful/key.lua | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/awesomerc.lua b/awesomerc.lua index 6e2a3a6a6..d01f13cee 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -372,6 +372,18 @@ awful.keyboard.append_global_keybindings({ end end end, + }, + awful.key { + modifiers = { modkey }, + keygroup = "numpad", + description = "select layout directly", + group = "layout", + on_press = function (index) + local t = awful.screen.focused().selected_tag + if t then + t.layout = t.layouts[index] or t.layout + end + end, } }) diff --git a/lib/awful/key.lua b/lib/awful/key.lua index 7879be2df..592bedde8 100644 --- a/lib/awful/key.lua +++ b/lib/awful/key.lua @@ -32,6 +32,10 @@ local gobject = require("gears.object") -- and its derivative. This is usually the number 1-9 followed by 0. -- * **arrows**: The Left/Right/Top/Bottom keys usually located right of the -- spacebar. +-- * **fkeys**: The keys F1 through F12 located at the topmost row of any +-- keyboard, plus F13 through F35 on specialist keyboards. +-- * **numpad**: The number keys on the keypad to the right of the letters and +-- the arrow keys. Not present in every keyboard. -- -- @property keygroup @@ -333,7 +337,20 @@ key.keygroups = { {"Right" , "Right" }, {"Up" , "Up" }, {"Down" , "Down" }, - } + }, + fkeys = {}, + numpad = { + {"#87" , 1}, + {"#88" , 2}, + {"#89" , 3}, + {"#83" , 4}, + {"#84" , 5}, + {"#85" , 6}, + {"#79" , 7}, + {"#80" , 8}, + {"#81" , 9}, + {"#90" , 10}, + }, } -- Technically, this isn't very popular, but we have been doing this for 12 @@ -341,6 +358,9 @@ key.keygroups = { for i = 1, 10 do table.insert(key.keygroups.numrow, {"#" .. i + 9, i == 10 and 0 or i}) end +for i = 1, 35 do + table.insert(key.keygroups.fkeys, {"F" .. i, "F" .. i}) +end -- Allow key objects to provide more than 1 key. --