Skip to content

Commit

Permalink
Add filterClients and cycleClientsByIdx configuration for window_swit…
Browse files Browse the repository at this point in the history
…cher widget (BlingCorp#162)
  • Loading branch information
Trial97 authored Jun 16, 2022
1 parent 4d2d8e5 commit c405103
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions docs/widgets/window_switcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ bling.widget.window_switcher.enable {
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_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
}
```

Expand Down
29 changes: 18 additions & 11 deletions widget/window_switcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ local function draw_widget(
name_focus_color,
icon_valign,
icon_width,
mouse_keys
mouse_keys,
filterClients
)
filterClients = filterClients or awful.widget.tasklist.filter.currenttags
local tasklist_widget = type == "thumbnail"
and awful.widget.tasklist({
screen = awful.screen.focused(),
filter = awful.widget.tasklist.filter.currenttags,
filter = filterClients,
buttons = mouse_keys,
style = {
font = name_font,
Expand Down Expand Up @@ -167,7 +169,7 @@ local function draw_widget(
})
or awful.widget.tasklist({
screen = awful.screen.focused(),
filter = awful.widget.tasklist.filter.currenttags,
filter = filterClients,
buttons = mouse_keys,
style = {
font = name_font,
Expand Down Expand Up @@ -274,6 +276,9 @@ local enable = function(opts)
local scroll_previous_key = opts.scroll_previous_key or 4
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({
bg = "#00000000",
visible = false,
Expand Down Expand Up @@ -308,15 +313,15 @@ local enable = function(opts)
modifiers = { "Any" },
button = scroll_previous_key,
on_press = function()
awful.client.focus.byidx(-1)
cycleClientsByIdx(-1)
end,
}),

awful.button({
modifiers = { "Any" },
button = scroll_next_key,
on_press = function()
awful.client.focus.byidx(1)
cycleClientsByIdx(1)
end,
})
)
Expand All @@ -343,21 +348,21 @@ local enable = function(opts)
end,

[cycle_key] = function()
awful.client.focus.byidx(1)
cycleClientsByIdx(1)
end,

[previous_key] = function()
awful.client.focus.byidx(1)
cycleClientsByIdx(1)
end,
[next_key] = function()
awful.client.focus.byidx(-1)
cycleClientsByIdx(-1)
end,

[vim_previous_key] = function()
awful.client.focus.byidx(1)
cycleClientsByIdx(1)
end,
[vim_next_key] = function()
awful.client.focus.byidx(-1)
cycleClientsByIdx(-1)
end,
}

Expand Down Expand Up @@ -445,8 +450,10 @@ local enable = function(opts)
name_focus_color,
icon_valign,
icon_width,
mouse_keys
mouse_keys,
filterClients
)
window_switcher_box.screen = awful.screen.focused()
window_switcher_box.visible = true
end)
end
Expand Down

0 comments on commit c405103

Please sign in to comment.