Closed TheKamboy closed 1 month ago
urgent_window
is a signal and not a property. neither Hyprland nor ags keeps track of which windows/worksapces are urgent. You have to do that yourself.
I modified your code to do that. I didn't test this but it might give you the right idea.
const Workspaces = (ws: number) => Widget.Box({
children: range(ws || 20).map(i => Widget.Label({
attribute: {
id: i,
isUrgent: false,
},
vpack: "center",
label: `${i}`,
setup: self => {
self.hook(hyprland, () => {
//unset urgent if ws gets focus
if(hyprland.active.workspace.id === i) self.attribute.isUrgent = false
self.toggleClassName("active", hyprland.active.workspace.id === i)
self.toggleClassName("occupied", (hyprland.getWorkspace(i)?.windows || 0) > 0)
self.toggleClassName("urgent", self.attribute.isUrgent)
})
self.hook(hyprland, (_, address) => {
//set urgent on ws containing the urgent window
if(hyprland.getClient(address).workspace.id == self.attribute.id) {
self.attribute.isUrgent = true
self.toggleClassName("urgent", self.attribute.isUrgent)
}
}, "urgent-window")
},
})),
setup: box => {
if (ws === 0) {
box.hook(hyprland.active.workspace, () => box.children.map(btn => {
btn.visible = hyprland.workspaces.some(ws => ws.id === btn.attribute.id)
}))
}
},
})
It worked! Thanks!
I'm not good with typescript so I can't explain much.
Here's the code for the workspaces thing on my bar:
With this code, this is the result:![image](https://github.com/Aylur/ags/assets/89111294/c76e9ed7-2e9d-4e5b-a42f-7ab98c783a5d)
What do I do so that it only makes it red when the workspace is urgent?