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

make waybar itself assign numbers to workspaces like sway #783

Merged
merged 2 commits into from
Jul 27, 2020

Conversation

f0rki
Copy link
Contributor

@f0rki f0rki commented Jul 22, 2020

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 .

auto l = lhs["num"].asInt();
auto r = rhs["num"].asInt();
//auto l = lhs["num"].asInt();
//auto r = rhs["num"].asInt();
Copy link
Owner

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?

Copy link
Contributor Author

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.

@f0rki
Copy link
Contributor Author

f0rki commented Jul 24, 2020

Btw @imjasonmiller and @mjec could you please confirm this fixes the issues you noticed on your setups?

@mjec
Copy link
Contributor

mjec commented Jul 24, 2020

@mjec could you please confirm this fixes the issues you noticed on your setups?

Yup this is a complete fix for what I reported as #777

@imjasonmiller
Copy link

@imjasonmiller ... 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:

image

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) {
Copy link
Owner

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 :)

Copy link
Contributor Author

@f0rki f0rki Jul 27, 2020

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?

Copy link
Owner

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.

Copy link
Contributor Author

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
@Alexays Alexays merged commit 1f6277e into Alexays:master Jul 27, 2020
@Alexays
Copy link
Owner

Alexays commented Jul 27, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants