From ce845ee2aa0efbfc0b8706e7933b1dff5749f24f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 2 Dec 2020 16:54:37 +0100 Subject: bindings: add bindings for moving clients between adjacent desktop pages --- bindings.lua | 15 +++++++++++++++ workspace.lua | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/bindings.lua b/bindings.lua index f23b074..f9db2d7 100644 --- a/bindings.lua +++ b/bindings.lua @@ -84,6 +84,21 @@ function M.create(workspace) awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), + -- move to upper/lower page + awful.key({ modkey, "Shift" }, "j", + function () + if client.focus then + local c = client.focus + workspace:client_move_relative(c, 1) + end + end), + awful.key({ modkey, "Shift" }, "k", + function () + if client.focus then + local c = client.focus + workspace:client_move_relative(c, -1) + end + end), -- Prompt awful.key({ modkey }, "n", diff --git a/workspace.lua b/workspace.lua index f0a6dcc..cb0eff1 100644 --- a/workspace.lua +++ b/workspace.lua @@ -157,6 +157,16 @@ function Workspace:move_client(client, desk, page) awful.client.movetotag(dst_page, client) end +function Workspace:client_move_relative(client, offset) + local state = self.screen_state[mouse.screen] + if state then + local desk = state.desktop_idx + local page = 1 + ((state.page_idx - 1 + offset) % #self.desktops[desk].pages) + + self:move_client(client, desk, page) + end +end + function Workspace:new(layouts) local o = setmetatable({}, self) self.__index = self -- cgit v1.2.3