rc.lua: Remove the numkey loop and use the awful.key keygroup.

The result is the same. One less imperative construct in `rc.lua`.
This commit is contained in:
Emmanuel Lepage Vallee 2019-11-18 02:04:48 -05:00
parent a53ff7418e
commit 1921d54528
1 changed files with 35 additions and 36 deletions

View File

@ -378,64 +378,63 @@ clientkeys = {
}
-- @DOC_NUMBER_KEYBINDINGS@
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do
-- View tag only.
awful.keyboard.append_global_keybinding(awful.key(
{ modkey }, "#" .. i + 9,
function ()
awful.keyboard.append_global_keybindings({
awful.key {
modifiers = { modkey },
keygroup = "numrow",
description = "only view tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[i]
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end,
{description = "view tag #"..i, group = "tag"}
))
-- Toggle tag display.
awful.keyboard.append_global_keybinding(awful.key(
{ modkey, "Control" }, "#" .. i + 9,
function ()
},
awful.key {
modifiers = { modkey, "Control" },
keygroup = "numrow",
description = "toggle tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[i]
local tag = screen.tags[index]
if tag then
awful.tag.viewtoggle(tag)
end
end,
{description = "toggle tag #" .. i, group = "tag"}
))
-- Move client to tag.
awful.keyboard.append_global_keybinding(awful.key(
{ modkey, "Shift" }, "#" .. i + 9,
function ()
},
awful.key {
modifiers = { modkey, "Shift" },
keygroup = "numrow",
description = "move focused client to tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[i]
local tag = client.focus.screen.tags[index]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
{description = "move focused client to tag #"..i, group = "tag"}
))
-- Toggle tag on focused client.
awful.keyboard.append_global_keybinding(awful.key(
{ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
},
awful.key {
modifiers = { modkey, "Control", "Shift" },
keygroup = "numrow",
description = "toggle focused client on tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[i]
local tag = client.focus.screen.tags[index]
if tag then
client.focus:toggle_tag(tag)
end
end
end,
{description = "toggle focused client on tag #" .. i, group = "tag"}
))
end
}
})
-- @DOC_CLIENT_BUTTONS@
clientbuttons = {