gh0stzk / dotfiles

BSPWM environment with 18 themes. With a theme selector to change on the fly.
GNU General Public License v3.0
2.46k stars 187 forks source link

Fix eww workspaces duplicating #249

Closed 0xN1nja closed 1 month ago

0xN1nja commented 1 month ago

Fixes https://github.com/gh0stzk/dotfiles/issues/207#issue-2198213495.

In the WorkSpaces script, you are looping through desktops:

for d in $desktops; do
        if [[ "$(contains "$focused_desktop" "$d")" -eq 1 ]]; then
            ws=$d
            icon="󰮯"
            class="workspace-focused"
        elif [[ "$(contains "$occupied_desktops" "$d")" -eq 1 ]]; then
            ws=$d
            icon="󰊠"
            class="workspace-occupied"
        else
            ws="$d"
            icon="󰑊"
            class="workspace-empty"
        fi

        buf+="(eventbox :cursor \"pointer\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon\"))"
    done

The output of which; bspc query -D --names, looks like this:

image

This is why workspaces are duplicating when connecting an external desktop.

I fixed this by piping the output of bspc query -D --names to sort and then piping the output of sort to uniq. Now the query looks like this:

image

And now workspaces are not duplicating anymore (when connecting an external desktop), and they are working just like the workspaces in polybar:

image image

0xN1nja commented 1 month ago

Workspaces on the bar used to look like this upon connecting an external monitor (before fixing):

image image

gh0stzk commented 1 month ago

Ohh nice solution, i will merge this, I have already applied your changes and I am testing but in the meantime I will accept the changes.