Add F-keys and numpad to `awful.key.keygroups`

Signed-off-by: ArenaL5 <arenal5@gmx.com>

Extend `fkeys` to F35

Signed-off-by: ArenaL5 <arenal5@gmx.com>

Reducing `numpad` to its most aggreable subset

Signed-off-by: ArenaL5 <arenal5@gmx.com>

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 <arenal5@gmx.com>
This commit is contained in:
ArenaL5 2020-03-22 01:13:37 +01:00
parent e97eeff187
commit 15929b0797
2 changed files with 33 additions and 1 deletions

View File

@ -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,
}
})

View File

@ -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.
--