Merge pull request #1678 from asas1asas200/zeng-feat-idle_inhibitor_tooltip

feat(idle-inhibitor): add tooltip format
This commit is contained in:
Alex 2022-09-05 17:52:27 +02:00 committed by GitHub
commit 38d2815425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();