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

Feature request: in hyprland/workspaces allow also for window title and regex #2561

Closed
euglevi opened this issue Oct 9, 2023 · 8 comments · Fixed by #2563
Closed

Feature request: in hyprland/workspaces allow also for window title and regex #2561

euglevi opened this issue Oct 9, 2023 · 8 comments · Fixed by #2563

Comments

@euglevi
Copy link

euglevi commented Oct 9, 2023

I think that the recent commit on Hyprland dynamic window names on workspaces (58e506a) by @Syndelis was very cool. It works very well in my setup. If I understood correctly, at the moment it is only possible to use the window class to set the icon. Would it be possible/easy to add also the window title and/or allow for regex strings? I am sorry that I cannot help with this as I am not really proficient in coding.

@Syndelis
Copy link
Contributor

Syndelis commented Oct 9, 2023

That's totally doable! The reason I didn't include it at first was because I was unsure of how to introduce both configurations at once: should there be two configuration parameters (ex. "window-rewrite-class" and "window-rewrite-title")? But if so, which should take precedence over the other?

Now that I gave it a second thought, maybe the following syntax?

"window-rewrite": {
  "class(firefox)": "",
  "title(.*youtube)": "󰗃"
}

I'd love your feedback on this. Later today I'll open a PR with that syntax, but I'm open for suggestions.

@euglevi
Copy link
Author

euglevi commented Oct 9, 2023

Thank you for taking up my proposal! The syntax you suggested looks fine to me. Better than having two separate configuration parameters. An even more advanced feature would be to allow for a combination of titles/classes. Maybe something like:

 "window-rewrite": {
  "class(firefox).title(.*facebook)": "",
}

where if you leave one of the two out, then it considers only classes or only titles. This combination could take precedence over the simple ones.

@Syndelis
Copy link
Contributor

Syndelis commented Oct 9, 2023

That's a good idea. Though, rather than using . (dot) to separate the attributes, maybe a whitespace or / (slash)? Something that isn't a regex special character.

My reasoning for that is: rather than writing a parser, I'll just use plain regex for matching. The window's final string to be matched against the rule will be constructed in runtime and look like this: "class(<window_class_here>) title(<window_title_here>)". Then, the user's configuration could use one, both or neither the attributes and still match correctly.

Of course a parser would be a better solution, but it's hard to maintain a custom one and I'd rather not bring on a new C++ dependency (I'd love bringing https://github.com/wrsturgeon/inator 🦀 on, however).

@euglevi
Copy link
Author

euglevi commented Oct 9, 2023

A slash or a whitespace both look like good solutions to me!

@euglevi
Copy link
Author

euglevi commented Oct 10, 2023

Thanks for all your work on this!

Now that I think of it, there could be another cool feature. Hyprctl also tells if the window is in fullscreen mode. It would be nice to have a graphical sign (asterisks, brackets, etc.) that tells when the window is maximized.

@Syndelis
Copy link
Contributor

While that would be pretty cool, I think Hyprland's socket2 could be a problem with this one. When a window enters/exists fullscreen, Hyprland's socket2 doesn't tell you which window:

image

While we could find out which one by calling socket1, I think that could be avoided by contributing to Hyprland itself, thus simpliflying the implementation in Waybar. I'm saying this because getting the Window's updated title required the same solution and it feels wrong to have to re-do the same steps all the time.

@euglevi
Copy link
Author

euglevi commented Oct 11, 2023

Could maybe another way be to retrieve the window id from the previous lines where it says the activewindow or the activewindowv2? Anyway, do not bother if it is too complicated and sorry that I cannot be of much assistance.

@gvolpe
Copy link

gvolpe commented May 14, 2024

Apologies for spamming this PR, but is it possible to have the same for hyprland/window? 🙏🏽 #2389

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 a pull request may close this issue.

3 participants