Aylur / astal

Building blocks for creating custom desktop shells
https://aylur.github.io/astal/
GNU Lesser General Public License v2.1
279 stars 35 forks source link

Hyprland monitor's active workspace doesn't update on `workspacev2` #130

Closed pynappo closed 1 day ago

pynappo commented 1 day ago

Describe the bug I use AGS on a multi-monitor setup, and I want to be able to differentiate visible/active workspaces from the rest. I used to be able to bind to the hyprland monitors and check each of their active workspaces, but it seems like switching workspaces doesn't update monitors at the moment:

https://github.com/Aylur/astal/blob/3e6c7eeb1c96b5afba82f5fdc2ab35c78f383b38/lib/hyprland/hyprland.vala#L310-L313

To Reproduce

hyprland.connect("event", (_, event, args) => {
  console.log(event, args);
  if (event === "workspacev2") {
    console.log({
      monitors: hyprland.monitors.map((m) => {
        return {
          activeId: m.activeWorkspace.id, // this should update as workspace changes
        };
      }),
    });
  }
});

-- edit: more verbose logging

Expected behavior Monitors should update on a workspace switch because they keep track of their active workspace. With the above script, this is what is logged when i switch workspace:

js-Message: 04:20:20.503: workspacev2 9,9
js-Message: 04:20:20.503: {
    "monitors": [
        {
            "activeId": 4
        },
        {
            "activeId": 3
        }
    ]
}

i'm expecting that one of the monitors changes their activeId to 9.

Additional context Also tried to debug this by trying to await sync_monitors, but it doesn't seem to ever return? Totally possible i am just unaware of what that method does:

hyprland.connect("event", async (_, event, args) => {
  console.log(event, args);
  // temp patch:
  if (event === "workspacev2") {
    console.log(hyprland.monitors);
    await hyprland.sync_monitors();
    // unreached
    console.log("synced?");
  }
});