Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
5.81k stars 656 forks source link

Enable using capture groups in window-rewrite #3331

Closed Eisfunke closed 2 weeks ago

Eisfunke commented 3 weeks ago

This uses std::match_results::format to format the output of get in RegexCollection using the match results.

The effect of this is that you can now use capture groups in the regexes in window-rewrite in the sway and hyprland workspaces modules, similarly to the window module, e.g. like this:

"window-rewrite": {
    "title<.* - (.*) - VSCodium>": "codium $1"  // captures part of the window title and formats it into output
}

This example would rewrite a window titled foo.cpp - Waybar - VSCodium to codium Waybar. This is quite useful to rewrite long window titles, but keeping relevant parts of the original title, in this example the workpsace of the VSCodium window.

I have only tested this with sway. Note that I don't know C++ very well so I hope I haven't accidentally introduced a memory leak or something like that.

Alexays commented 2 weeks ago

Thanks!