diff --git a/awesome/keys.lua b/awesome/keys.lua index fe76a87..334e420 100644 --- a/awesome/keys.lua +++ b/awesome/keys.lua @@ -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"} ), -- =========================================