Closed weeebdev closed 3 months ago
You should be able to adapt your space app together with space windows plugin.
You should be able to adapt your space app together with space windows plugin.
For now I decided to go on like this:
local apps = sbar.add("bracket", "apps", {}, {
position = "left",
label = {
font = {
style = settings.font.style_map["Black"],
size = 12.0,
},
},
})
local function focus_window(env)
sbar.exec("yabai -m query --windows id,has-focus", function(output)
for _, line in ipairs(output) do
sbar.set("apps." .. line.id, {
label = {
highlight = line['has-focus'],
}
})
end
end)
end
local function update_windows(windows)
-- need to check if exists
sbar.remove("/apps.\\.*/")
for _, line in ipairs(windows) do
width = 655 / #windows
sbar.add("item", "apps." .. line['id'], {
label = {
string = line['app'],
max_chars = width,
scroll_duration = 150,
width = width,
highlight_color = colors.magenta,
highlight = line['has-focus'],
},
padding_right = 2,
click_script = "yabai -m window --focus " .. line['id'],
background = {
color = colors.black,
height = 14,
corner_radius = 0,
border_width = 1,
border_color = colors.cyan
},
})
end
end
local function get_apps(env)
sbar.exec("yabai -m query --windows id,title,app,has-focus --space", update_windows)
end
apps:subscribe("space_change", get_apps)
apps:subscribe("front_app_switched", focus_window)
I want to create a dynamic list similar to spaces, but for opened windows in the current space. So I need a container which I could populate with items and clear when space is changed.