add new widgets; rewrite workspace indicator

This commit is contained in:
gnat
2024-11-17 16:27:41 -08:00
parent 784e71e643
commit d584d25194
5 changed files with 125 additions and 10 deletions

View File

@ -1,4 +1,4 @@
local Hyprland <const> = astal.require("AstalHyprland")
local Hyprland <const> = lgi.require("AstalHyprland")
local map, sequence = require('lua.lib').map, require('lua.lib').sequence
local hypr = Hyprland.get_default()
@ -15,18 +15,26 @@ local function workspace_row(start, stop)
self:hook(hypr, 'notify::focused-workspace', function(self, workspace)
self:toggle_class_name('focused', workspace:get_id() == i)
end)
self:hook(hypr, 'notify::workspaces', function(self, workspaces)
map(workspaces, function(workspace)
local function update()
local workspaces = hypr:get_workspaces()
for _,workspace in ipairs(workspaces) do
if workspace:get_id() == i then
-- ick
local count = 0
for _ in ipairs(workspace:get_clients()) do
local count = 0;
for _ in pairs(workspace:get_clients()) do
count = count + 1
end
self:toggle_class_name('occupied', workspace:get_id() == i and count > 0)
self:toggle_class_name('occupied', count > 0)
end
end)
end)
end
end
self:hook(hypr, 'notify::clients', update)
self:hook(hypr, 'notify::workspaces', update)
update()
end,
on_click_release = function()
hypr:message_async(string.format("dispatch workspace %d", i))
@ -41,6 +49,7 @@ return Widget.Box({
vertical = true,
hexpand = false,
halign = 'START',
valign = 'CENTER',
children = {
workspace_row(1, 5),
workspace_row(6, 10),