From 1921d545280c7dfbc99553a560afb42b822dbdc7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 18 Nov 2019 02:04:48 -0500 Subject: [PATCH] rc.lua: Remove the numkey loop and use the awful.key keygroup. The result is the same. One less imperative construct in `rc.lua`. --- awesomerc.lua | 71 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 25b355c74..11d4cf821 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -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 = {