Created
December 13, 2019 02:54
-
-
Save lmanul/9ca7ed31c65cbaaafbb352ddbbde4ddd to your computer and use it in GitHub Desktop.
AwesomeWM 2D tag grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows = 2 | |
columns = 3 | |
function grid(direction) | |
local t = awful.screen.focused().selected_tag | |
local i = t.index - 1 | |
local c = columns | |
local r = rows | |
-- 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] | |
-- Switch tags on all screens at the same time. | |
for s in screen do | |
t = s.tags[j] | |
if t then t:view_only() end | |
end | |
end | |
globalkeys = awful.util.table.join( | |
-- Tag navigation | |
awful.key(tag_nav_mod_keys, "Up", function () grid("up") end, {description = "Up", group="Tag"}), | |
awful.key(tag_nav_mod_keys, "Down", function () grid("down") end, {description = "Down", group="Tag"}), | |
awful.key(tag_nav_mod_keys, "Left", function () grid("left") end, {description = "Left", group="Tag"}), | |
awful.key(tag_nav_mod_keys, "Right", function () grid("right") end, {description = "Right", group="Tag"}), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment