From 8e5df7f49b4e05760312a2f86104fcdde5bdb515 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 2 Dec 2020 17:55:09 +0100 Subject: bindings: fix/improve desktop-switching Fix accessing desktops 11/12, as F11/F12 keycodes are discontinous with F1-F10. Add a set of bindings to send a client to specified desk. --- bindings.lua | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/bindings.lua b/bindings.lua index fb0f331..3746ae3 100644 --- a/bindings.lua +++ b/bindings.lua @@ -175,22 +175,36 @@ function M.create(workspace) end)) end + -- Switching between desktops for i = 1, 12 do + local keycode + if i <= 10 then + -- F1--10 are codes 67-76 + keycode = 66 + i + else + -- F11-12 are codes 95-96 + keycode = 84 + i + end + globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 66, - function () - local screen = mouse.screen - workspace:view(screen, i) - end), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function () - if client.focus then - local c = client.focus - workspace:move_client(c, workspace.screen_state[c.screen].desktop_idx, i) - end - end)) + -- View auto-selected page on desktop + awful.key({ modkey }, "#" .. keycode, + function () + local screen = mouse.screen + workspace:view(screen, i) + end), + + -- Move focused client to empty (or first, if all non-empty) + -- page on desktop + awful.key({ modkey, "Shift" }, "#" .. keycode, + function () + if client.focus then + local c = client.focus + local desk = workspace.desktops[i] + local page_idx = desk:find_empty_page() or 1 + workspace:move_client(c, i, page_idx) + end + end)) end local clientkeys = gears.table.join( -- cgit v1.2.3