Hyprland Workspaces Bind Triggers Twice
Hello!
I noticed some odd behavior which, while technically not causing any issues can significantly degrade performance depending on the complexity of any given widget.
I have this test widget:
const WorkspaceTest = () => Widget.Label({
label: Hyprland.bind('workspaces').transform(_ => {
console.log("here")
return ""
})
})
that demonstrates the behavior. Essentially, on either switching to another workspace, or opening a new window (but NOT closing a window or updating a window's state, these acts normally), here will in this case be printed twice. I believe that it should only be printed once as there has only been one update in both of these scenarios.
thanks!
Are you sure you are not instantiating two of these? it works as expected when I tried
let count = 0;
Hyprland.connect('notify::workspaces', () => {
print(count++)
})
This behavior only occurs when using the bind function. (in fact none of the workspaces services like workspace-added, or workspace-removed seem to do anything either).
const Workspaces = () => Widget.Box({
class_name: 'workspaces',
children: Hyprland.bind('workspaces').transform(_ => {
console.log("Hello")
})
})
this was the bit of code I used to test it again. You're right that the connect method works normally, however it is quite difficult to use anything other than the bind method I have found.
Hyprland.bind('workspaces').transform() will result to Hyprland.connect('notify::workspaces'), so the two snippets are essentially same
I tried your snippet too, and It works as expected for me, but I discovered that changing a song on the spotify client indeed fires it off twice because the windowtitle event is signaled twice from the Hyprland socket.
I think this is an issue with some clients
Hyprland.connect('event', (_, e, a) => print(a, e))
Are you using Hyprland? Just moving between windows or switching workspaces triggers it for me