Merge pull request #2269 from Arcus92/master
wlr/taskbar: add support for rewrite rulespull/1872/head^2
commit
65f73d3e95
|
@ -81,6 +81,10 @@ Addressed by *wlr/taskbar*
|
||||||
typeof: object ++
|
typeof: object ++
|
||||||
Dictionary of app_id to be replaced with
|
Dictionary of app_id to be replaced with
|
||||||
|
|
||||||
|
*rewrite*: ++
|
||||||
|
typeof: object ++
|
||||||
|
Rules to rewrite the module format output. See *rewrite rules*.
|
||||||
|
|
||||||
# FORMAT REPLACEMENTS
|
# FORMAT REPLACEMENTS
|
||||||
|
|
||||||
*{icon}*: The icon of the application.
|
*{icon}*: The icon of the application.
|
||||||
|
@ -109,6 +113,18 @@ Addressed by *wlr/taskbar*
|
||||||
|
|
||||||
*close*: Close the application.
|
*close*: Close the application.
|
||||||
|
|
||||||
|
# REWRITE RULES
|
||||||
|
|
||||||
|
*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.
|
||||||
|
|
||||||
|
Regular expression and replacement follow ECMA-script rules.
|
||||||
|
|
||||||
|
If no expression matches, the format output is left unchanged.
|
||||||
|
|
||||||
|
Invalid expressions (e.g., mismatched parentheses) are skipped.
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -124,6 +140,10 @@ Addressed by *wlr/taskbar*
|
||||||
],
|
],
|
||||||
"app_ids-mapping": {
|
"app_ids-mapping": {
|
||||||
"firefoxdeveloperedition": "firefox-developer-edition"
|
"firefoxdeveloperedition": "firefox-developer-edition"
|
||||||
|
},
|
||||||
|
"rewrite": {
|
||||||
|
"Firefox Web Browser": "Firefox",
|
||||||
|
"Foot Server": "Terminal"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "util/format.hpp"
|
#include "util/format.hpp"
|
||||||
#include "util/string.hpp"
|
#include "util/string.hpp"
|
||||||
|
|
||||||
|
#include "util/rewrite_string.hpp"
|
||||||
|
|
||||||
namespace waybar::modules::wlr {
|
namespace waybar::modules::wlr {
|
||||||
|
|
||||||
/* Icon loading functions */
|
/* Icon loading functions */
|
||||||
|
@ -622,6 +624,9 @@ void Task::update() {
|
||||||
fmt::format(fmt::runtime(format_before_), fmt::arg("title", title), fmt::arg("name", name),
|
fmt::format(fmt::runtime(format_before_), fmt::arg("title", title), fmt::arg("name", name),
|
||||||
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
||||||
fmt::arg("short_state", state_string(true)));
|
fmt::arg("short_state", state_string(true)));
|
||||||
|
|
||||||
|
txt = waybar::util::rewriteString(txt, config_["rewrite"]);
|
||||||
|
|
||||||
if (markup)
|
if (markup)
|
||||||
text_before_.set_markup(txt);
|
text_before_.set_markup(txt);
|
||||||
else
|
else
|
||||||
|
@ -633,6 +638,9 @@ void Task::update() {
|
||||||
fmt::format(fmt::runtime(format_after_), fmt::arg("title", title), fmt::arg("name", name),
|
fmt::format(fmt::runtime(format_after_), fmt::arg("title", title), fmt::arg("name", name),
|
||||||
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
||||||
fmt::arg("short_state", state_string(true)));
|
fmt::arg("short_state", state_string(true)));
|
||||||
|
|
||||||
|
txt = waybar::util::rewriteString(txt, config_["rewrite"]);
|
||||||
|
|
||||||
if (markup)
|
if (markup)
|
||||||
text_after_.set_markup(txt);
|
text_after_.set_markup(txt);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue