-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
make waybar itself assign numbers to workspaces like sway #783
Conversation
…ybar to handle perisstent workspaces
src/modules/sway/workspaces.cpp
Outdated
auto l = lhs["num"].asInt(); | ||
auto r = rhs["num"].asInt(); | ||
//auto l = lhs["num"].asInt(); | ||
//auto r = rhs["num"].asInt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we keep it as a fallback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but this way waybar is completely independent from how sway assigns the num
property resulting in less unexpected behaviour in waybar, in case sway ever changes the way the num
property is set.
Btw @imjasonmiller and @mjec could you please confirm this fixes the issues you noticed on your setups? |
Lovely! I just built it and it works. Here's two instances of Waybar running, with the above being the fixed version: |
src/modules/sway/workspaces.cpp
Outdated
namespace waybar::modules::sway { | ||
|
||
// this is the code that sway uses to assign a number to a workspace. This is | ||
// taken quite verbatim from `sway/ipc-json.c`. | ||
int sway_wsname_to_num(std::string name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just move this func as a method of Workspaces class, and i'll merge this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really needed? The the lambda used in the std::sort
call would then need to capture this
as well, not sure whether this has any negative impact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least a static method, that's just in order to avoid anonymous func outside the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alexays done :)
…hod of Workspaces class and adapted comments/method name to be consistent with the rest
Thanks! |
sway assigns a "num" property to every workspace and this PR copies the logic of sway into waybar. While this is duplicated effort, it seems to be needed to properly sort persistent workspace, which might not exist in the sway IPC response, but needs something like the "num" property anyway.
Not sure this is really the best way but it seems to fix the issue #777 and the comment in the PR #696 .