From 2dbb212f75ca9e18d5e5245fbbeed5bb5b40c52d Mon Sep 17 00:00:00 2001 From: Manu Cornet Date: Tue, 14 Dec 2021 06:13:48 +0000 Subject: [PATCH] Initial version --- awesome-workspace-grid.lua | 55 ++++++++++++++++++++++++++++++++++++++ init.lua | 1 + 2 files changed, 56 insertions(+) create mode 100644 awesome-workspace-grid.lua create mode 120000 init.lua diff --git a/awesome-workspace-grid.lua b/awesome-workspace-grid.lua new file mode 100644 index 0000000..d802630 --- /dev/null +++ b/awesome-workspace-grid.lua @@ -0,0 +1,55 @@ +local awful = require("awful") + +local workspace_grid = {} + +function workspace_grid:new(args) + return setmetatable({}, {__index = self}):init(args) +end + +function workspace_grid:init(args) + self.test = 0 + return self +end + +local rows = 2 +local columns = 3 + +function workspace_grid:navigate(direction) + log(tostring(direction)) + local t = awful.screen.focused().selected_tag + local i = t.index - 1 + local c = columns + local r = rows + log("Rows " .. tostring(rows)) + log("Cols" .. tostring(columns)) + + -- Don't cycle. + -- Top row + if (i < c) and (direction == "up") then return true end + -- Left column + if (i % c == 0) and (direction == "left") then return true end + -- Right column + if ((i + 1) % c == 0) and (direction == "right") then return true end + -- Bottom row + if (i >= (r - 1) * c) and (direction == "down") then return true end + + action = { + ["down"] = (i + columns) % (rows * columns) + 1, + ["up"] = (i - columns) % (rows * columns) + 1, + ["left"] = (math.ceil((i + 1) / columns) - 1) * columns + ((i - 1) % columns) + 1, + ["right"] = (math.ceil((i + 1) / columns) - 1) * columns + ((i + 1) % columns) + 1, + } + local j = action[direction] + log(tostring(j)) + + -- Switch tags on all screens at the same time. + for s in screen do + log(tostring(s)) + t = s.tags[j] + if t then t:view_only() end + end +end + +return setmetatable(workspace_grid, { + __call = workspace_grid.new, +}) diff --git a/init.lua b/init.lua new file mode 120000 index 0000000..0693060 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +awesome-workspace-grid.lua \ No newline at end of file