Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sway/workspaces] Persistent workspaces always appear first if not created by sway #777

Closed
mjec opened this issue Jul 20, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@mjec
Copy link
Contributor

mjec commented Jul 20, 2020

Given a persistent workspaces configuration, if any workspace has not been created (i.e. does not appear in swaymsg -t get_workspaces), that workspace button will always appear first in sway.

I believe this is because since 6fe7645 the workspace num property is used for sort order, however that is not set for persistent workspaces. I believe it's therefore cast to zero, appearing first.

One consequence of this is that switching to such a workspace causes the workspace button to jump to the correct position.

The fix for this isn't obvious to me. We could set the num property to -1, which would result in these being grouped with non-numeric workspaces, and their position dependent on the numeric-first config parameter. However this behavior is a little inconsistent, as persistent workspaces may be numeric. This will still, I assume, make the workspace button jump around when changing to that workspace.

My best idea so far is to set num to the strtoi of the workspace name, or -1 if strtoi fails. This should mirror the behavior of sway, which should at least prevent the button jumping around. The downside is that if sway's behavior ever changes, this will break.

I'm open to ideas here, and happy to code up whatever is decided as the best approach.

@f0rki
Copy link
Contributor

f0rki commented Jul 22, 2020

For reference, there are some comments with screenshots in the pull request that lead to this problem: #696

My best idea so far is to set num to the strtoi of the workspace name, or -1 if strtoi fails. This should mirror the behavior of sway, which should at least prevent the button jumping around.

This is something I thought of doing before discovering sway's "num" property, which was simply easier to reuse in my PR.

The downside is that if sway's behavior ever changes, this will break.

I would suggest to simply not use the "num" property anymore. If the "num" property is ignored completely by waybar and the logic of assigning a number to a workspace is duplicated in waybar, then waybar will be independent of sway's "num" assignments. Since this is only used for ordering and displaying, this should not cause too much trouble even if waybar and sway disagree on the workspace "num" in the future.

EDIT: I did this in my PR #783

@Alexays
Copy link
Owner

Alexays commented Jul 27, 2020

Fixed by #783 🎉

@Alexays Alexays closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants