Add filterClients and cycleClientsByIdx configuration for window_switcher widget (#162)

This commit is contained in:
Alexandru Ionut Tripon 2022-06-16 22:40:11 +03:00 committed by GitHub
parent 4d2d8e5e27
commit c405103262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

View File

@ -24,6 +24,9 @@ bling.widget.window_switcher.enable {
next_key = "Right", -- The key on which to select the next client next_key = "Right", -- The key on which to select the next client
vim_previous_key = "h", -- Alternative key on which to select the previous client vim_previous_key = "h", -- Alternative key on which to select the previous client
vim_next_key = "l", -- Alternative key on which to select the next client vim_next_key = "l", -- Alternative key on which to select the next client
cycleClientsByIdx = awful.client.focus.byidx, -- The function to cycle the clients
filterClients = awful.widget.tasklist.filter.currenttags, -- The function to filter the viewed clients
} }
``` ```

View File

@ -84,12 +84,14 @@ local function draw_widget(
name_focus_color, name_focus_color,
icon_valign, icon_valign,
icon_width, icon_width,
mouse_keys mouse_keys,
filterClients
) )
filterClients = filterClients or awful.widget.tasklist.filter.currenttags
local tasklist_widget = type == "thumbnail" local tasklist_widget = type == "thumbnail"
and awful.widget.tasklist({ and awful.widget.tasklist({
screen = awful.screen.focused(), screen = awful.screen.focused(),
filter = awful.widget.tasklist.filter.currenttags, filter = filterClients,
buttons = mouse_keys, buttons = mouse_keys,
style = { style = {
font = name_font, font = name_font,
@ -167,7 +169,7 @@ local function draw_widget(
}) })
or awful.widget.tasklist({ or awful.widget.tasklist({
screen = awful.screen.focused(), screen = awful.screen.focused(),
filter = awful.widget.tasklist.filter.currenttags, filter = filterClients,
buttons = mouse_keys, buttons = mouse_keys,
style = { style = {
font = name_font, font = name_font,
@ -274,6 +276,9 @@ local enable = function(opts)
local scroll_previous_key = opts.scroll_previous_key or 4 local scroll_previous_key = opts.scroll_previous_key or 4
local scroll_next_key = opts.scroll_next_key or 5 local scroll_next_key = opts.scroll_next_key or 5
local cycleClientsByIdx = opts.cycleClientsByIdx or awful.client.focus.byidx
local filterClients = opts.filterClients or awful.widget.tasklist.filter.currenttags
local window_switcher_box = awful.popup({ local window_switcher_box = awful.popup({
bg = "#00000000", bg = "#00000000",
visible = false, visible = false,
@ -308,7 +313,7 @@ local enable = function(opts)
modifiers = { "Any" }, modifiers = { "Any" },
button = scroll_previous_key, button = scroll_previous_key,
on_press = function() on_press = function()
awful.client.focus.byidx(-1) cycleClientsByIdx(-1)
end, end,
}), }),
@ -316,7 +321,7 @@ local enable = function(opts)
modifiers = { "Any" }, modifiers = { "Any" },
button = scroll_next_key, button = scroll_next_key,
on_press = function() on_press = function()
awful.client.focus.byidx(1) cycleClientsByIdx(1)
end, end,
}) })
) )
@ -343,21 +348,21 @@ local enable = function(opts)
end, end,
[cycle_key] = function() [cycle_key] = function()
awful.client.focus.byidx(1) cycleClientsByIdx(1)
end, end,
[previous_key] = function() [previous_key] = function()
awful.client.focus.byidx(1) cycleClientsByIdx(1)
end, end,
[next_key] = function() [next_key] = function()
awful.client.focus.byidx(-1) cycleClientsByIdx(-1)
end, end,
[vim_previous_key] = function() [vim_previous_key] = function()
awful.client.focus.byidx(1) cycleClientsByIdx(1)
end, end,
[vim_next_key] = function() [vim_next_key] = function()
awful.client.focus.byidx(-1) cycleClientsByIdx(-1)
end, end,
} }
@ -445,8 +450,10 @@ local enable = function(opts)
name_focus_color, name_focus_color,
icon_valign, icon_valign,
icon_width, icon_width,
mouse_keys mouse_keys,
filterClients
) )
window_switcher_box.screen = awful.screen.focused()
window_switcher_box.visible = true window_switcher_box.visible = true
end) end)
end end