-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Add option to rewrite sway/window title #1055
Conversation
Failed test seems to be caused by the runner, not by the changed code:
|
@Alexays is anything missing? |
LGTM, can you update the man in order to add the change? |
Very cool, using this locally and it's working like a charm! +1 for this feature. |
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.
Actually, I'd like to request 1 change: if the regex is malformed in some way, it's probably better to keep the window title unchanged rather than crapping out completely and not setting the window title at all as is currently the case.
Rewrites window title according to config option "rewrite". "rewrite" is an object where keys are regular expressions and values are rewrite rules if the expression matches. Rules may contain references to captures of the expression. Regex and replacement follow ECMA-script rules. If no regex matches, the title is left unchanged. example: "sway/window": { "rewrite": { "(.*) - Mozilla Firefox": " $1", "(.*) - zsh": " $1", } }
std::regex and std::regex_replace may throw an std::regex_error if the expression or replacement contain errors. Log this error and carry on with the next rule, so that the title is shown even if the config contains errors.
Add section on rewrite rules and extend example
6a1a0f5
to
7cdf178
Compare
@Synthetica9 Good catch. Added try/catch around the regex stuff to fix this issue @Alexays Added documentation in manpage and rebased on current master. |
Thx! ❤️ |
@Alexays done :) |
Rewrites window title according to config option "rewrite".
"rewrite" is an object where keys are regular expressions and values are rewrite rules if the expression matches. Rules may contain references to captures of the expression. Regex and replacement follow ECMA-script rules. If no regex matches, the title is left unchanged.
Useful to add icons depending on the window title, e.g.:
Examples: