Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
1.74k stars 94 forks source link

Status Bar lists workspaces out of order #470

Open bratfizyk opened 1 week ago

bratfizyk commented 1 week ago

According to docs, to Workspaces part of the Status bar is based on the output of hyprctl workspaces -j.

I haven't checked its docs, but from my experience it lists workspaces based on the time they were created, without sorting. e.g.

image

As a solution, it is possible to add sorting to the Widget, e.g. something like this:

function Workspaces() {
    const activeId = hyprland.active.workspace.bind("id")
    const workspaces =
        hyprland.bind("workspaces")
            .as(ws => 
                ws.sort(({id:a},{id:b}) => a - b)
                .map(({ id }) => Widget.Button({
                    on_clicked: () => hyprland.messageAsync(`dispatch workspace ${id}`),
                    child: Widget.Label(`${id}`),
                    class_name: activeId.as(i => `${i === id ? "focused" : ""}`),
                }
            ))
        )

    return Widget.Box({
        class_name: "workspaces",
        children: workspaces,
    })
}

I'm happy to create a PR for this it this is what you want.

yari-dog commented 1 week ago

there is the option to just write your own workspace service to do this for you. I wrote a wrapper for the notification service to help me filter out specific notifications from specific places