diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-12-02 17:55:09 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-12-02 17:55:09 +0100 |
commit | 8e5df7f49b4e05760312a2f86104fcdde5bdb515 (patch) | |
tree | 186a62b9ce605f8c5ee93992f5411badf82369f8 | |
parent | b61cabb6d1fd3d7fd76f64743c431175bc0e5363 (diff) |
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.
-rw-r--r-- | bindings.lua | 42 |
1 files 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 <i> + 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 <i> + 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( |