modify alt-tab behaviour

This commit is contained in:
Thomas Avé 2023-05-25 17:47:26 +02:00
parent e36f3889d8
commit 52d8678aac
1 changed files with 59 additions and 4 deletions

View File

@ -307,15 +307,70 @@ keys.globalkeys = gears.table.join(
-- Focus client by index (cycle through clients)
awful.key({modkey}, "Tab",
function()
awful.client.focus.byidx(1)
local screen = awful.screen.focused()
local tags = screen.tags
local current_tag = screen.selected_tag
local used_tags = {}
for _, t in ipairs(tags) do
if t == current_tag or #t:clients() > 0 then
table.insert(used_tags, t)
end
end
local found = false
for _, t in ipairs(used_tags) do
if found then
t:view_only()
return
elseif t == current_tag then
found = true
end
end
used_tags[1]:view_only()
end,
{description = "focus next by index", group = "client"}
{description = "Switch to next tag", group = "client"}
),
awful.key({modkey, "Shift"}, "Tab",
function()
awful.client.focus.byidx(-1)
local tags = root.tags()
local current_tag = awful.screen.focused().selected_tag
local used_tags = {}
for _, t in ipairs(tags) do
if t == current_tag or #t:clients() > 0 then
table.insert(used_tags, t)
end
end
local found = false
for _, t in ipairs(used_tags) do
if found then
awful.screen.focus(t.screen.index)
t:view_only()
return
elseif t == current_tag then
found = true
end
end
used_tags[1]:view_only()
end,
{description = "focus previous by index", group = "client"}
{description = "Switch to next tag", group = "client"}
),
-- Focus client by index (cycle through clients)
awful.key({modkey}, "t",
function()
local screen = awful.screen.focused()
local tags = screen.tags
local first_empty = nil
for _, t in ipairs(tags) do
if #t:clients() > 0 then
first_empty = nil
elseif first_empty == nil then
first_empty = t
end
end
if first_empty ~= nil then
first_empty:view_only()
end
end,
{description = "Switch to next tag", group = "client"}
),
-- =========================================