From 48ac59c0b6b730524265abb4b240f4aa6b8a8e26 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 22:51:35 -0500 Subject: [PATCH] rc.lua: Use the new keys API for the global keys. --- awesomerc.lua | 99 +++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 918318bf..4b0ad9b6 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -228,7 +228,7 @@ root.buttons = { -- {{{ Key bindings -- @DOC_GLOBAL_KEYBINDINGS@ -globalkeys = gears.table.join( +globalkeys = { awful.key({ modkey, }, "s", hotkeys_popup.show_help, {description="show help", group="awesome"}), awful.key({ modkey, }, "Left", awful.tag.viewprev, @@ -326,8 +326,8 @@ globalkeys = gears.table.join( {description = "lua execute prompt", group = "awesome"}), -- Menubar awful.key({ modkey }, "p", function() menubar.show() end, - {description = "show the menubar", group = "launcher"}) -) + {description = "show the menubar", group = "launcher"}), +} -- @DOC_CLIENT_KEYBINDINGS@ clientkeys = { @@ -379,49 +379,54 @@ clientkeys = { -- 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 - globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, - {description = "view tag #"..i, group = "tag"}), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - {description = "toggle tag #" .. i, group = "tag"}), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - 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.key({ modkey, "Control", "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, - {description = "toggle focused client on tag #" .. i, group = "tag"}) + -- View tag only. + table.insert(globalkeys, awful.key({ modkey }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + {description = "view tag #"..i, group = "tag"}) + ) + + -- Toggle tag display. + table.insert(globalkeys, awful.key({ modkey, "Control" }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}) + ) + + -- Move client to tag. + table.insert(globalkeys, awful.key({ modkey, "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + 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. + table.insert(globalkeys, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) ) end @@ -441,7 +446,7 @@ clientbuttons = { } -- Set keys -root.keys(globalkeys) +root.keys = globalkeys -- }}} -- {{{ Rules