feat(idle-inhibitor): add tooltip format

This commit is contained in:
asas1asas200 2022-09-03 19:21:32 +08:00
parent 4deb6d812d
commit 55e83f90d1
2 changed files with 19 additions and 1 deletions

View File

@ -72,6 +72,14 @@ screensaving, also known as "presentation mode".
default: true ++
Option to disable tooltip on hover.
*tooltip-format-activated*: ++
typeof: string ++
This format is used when the inhibit is activated.
*tooltip-format-deactivated*: ++
typeof: string ++
This format is used when the inhibit is deactivated.
# FORMAT REPLACEMENTS
*{status}*: status (*activated* or *deactivated*)

View File

@ -62,7 +62,17 @@ auto waybar::modules::IdleInhibitor::update() -> void {
fmt::arg("icon", getIcon(0, status_text))));
label_.get_style_context()->add_class(status_text);
if (tooltipEnabled()) {
label_.set_tooltip_text(status_text);
label_.set_tooltip_markup(
status ? fmt::format(config_["tooltip-format-activated"].isString()
? config_["tooltip-format-activated"].asString()
: "{status}",
fmt::arg("status", status_text),
fmt::arg("icon", getIcon(0, status_text)))
: fmt::format(config_["tooltip-format-deactivated"].isString()
? config_["tooltip-format-deactivated"].asString()
: "{status}",
fmt::arg("status", status_text),
fmt::arg("icon", getIcon(0, status_text))));
}
// Call parent update
ALabel::update();