rc.lua: Use the new keys API for the global keys.

This commit is contained in:
Emmanuel Lepage Vallee 2018-12-26 22:51:35 -05:00
parent 965d7c1b47
commit 48ac59c0b6
1 changed files with 52 additions and 47 deletions

View File

@ -228,7 +228,7 @@ root.buttons = {
-- {{{ Key bindings -- {{{ Key bindings
-- @DOC_GLOBAL_KEYBINDINGS@ -- @DOC_GLOBAL_KEYBINDINGS@
globalkeys = gears.table.join( globalkeys = {
awful.key({ modkey, }, "s", hotkeys_popup.show_help, awful.key({ modkey, }, "s", hotkeys_popup.show_help,
{description="show help", group="awesome"}), {description="show help", group="awesome"}),
awful.key({ modkey, }, "Left", awful.tag.viewprev, awful.key({ modkey, }, "Left", awful.tag.viewprev,
@ -326,8 +326,8 @@ globalkeys = gears.table.join(
{description = "lua execute prompt", group = "awesome"}), {description = "lua execute prompt", group = "awesome"}),
-- Menubar -- Menubar
awful.key({ modkey }, "p", function() menubar.show() end, awful.key({ modkey }, "p", function() menubar.show() end,
{description = "show the menubar", group = "launcher"}) {description = "show the menubar", group = "launcher"}),
) }
-- @DOC_CLIENT_KEYBINDINGS@ -- @DOC_CLIENT_KEYBINDINGS@
clientkeys = { clientkeys = {
@ -379,49 +379,54 @@ clientkeys = {
-- Be careful: we use keycodes to make it work on any keyboard layout. -- 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. -- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do for i = 1, 9 do
globalkeys = gears.table.join(globalkeys, -- View tag only.
-- View tag only. table.insert(globalkeys, awful.key({ modkey }, "#" .. i + 9,
awful.key({ modkey }, "#" .. i + 9, function ()
function () local screen = awful.screen.focused()
local screen = awful.screen.focused() local tag = screen.tags[i]
local tag = screen.tags[i] if tag then
if tag then tag:view_only()
tag:view_only() end
end end,
end, {description = "view tag #"..i, group = "tag"})
{description = "view tag #"..i, group = "tag"}), )
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9, -- Toggle tag display.
function () table.insert(globalkeys, awful.key({ modkey, "Control" }, "#" .. i + 9,
local screen = awful.screen.focused() function ()
local tag = screen.tags[i] local screen = awful.screen.focused()
if tag then local tag = screen.tags[i]
awful.tag.viewtoggle(tag) if tag then
end awful.tag.viewtoggle(tag)
end, end
{description = "toggle tag #" .. i, group = "tag"}), end,
-- Move client to tag. {description = "toggle tag #" .. i, group = "tag"})
awful.key({ modkey, "Shift" }, "#" .. i + 9, )
function ()
if client.focus then -- Move client to tag.
local tag = client.focus.screen.tags[i] table.insert(globalkeys, awful.key({ modkey, "Shift" }, "#" .. i + 9,
if tag then function ()
client.focus:move_to_tag(tag) if client.focus then
end local tag = client.focus.screen.tags[i]
end if tag then
end, client.focus:move_to_tag(tag)
{description = "move focused client to tag #"..i, group = "tag"}), end
-- Toggle tag on focused client. end
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, end,
function () {description = "move focused client to tag #"..i, group = "tag"})
if client.focus then )
local tag = client.focus.screen.tags[i]
if tag then -- Toggle tag on focused client.
client.focus:toggle_tag(tag) table.insert(globalkeys, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
end function ()
end if client.focus then
end, local tag = client.focus.screen.tags[i]
{description = "toggle focused client on tag #" .. i, group = "tag"}) if tag then
client.focus:toggle_tag(tag)
end
end
end,
{description = "toggle focused client on tag #" .. i, group = "tag"})
) )
end end
@ -441,7 +446,7 @@ clientbuttons = {
} }
-- Set keys -- Set keys
root.keys(globalkeys) root.keys = globalkeys
-- }}} -- }}}
-- {{{ Rules -- {{{ Rules