Merge pull request #2923 from jones-josh/custom-tooltip-format

Add check for tooltip-format for custom modules
pull/1899/merge
Alexis Rouillard 2024-02-19 22:47:22 +01:00 committed by GitHub
commit 9191cae13b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -107,6 +107,11 @@ Addressed by *custom/<name>*
default: true ++
Option to disable tooltip on hover.
*tooltip-format*: ++
typeof: string ++
The tooltip format. If specified, overrides any tooltip output from the script in *exec*. ++
Uses the same format replacements as *format*.
*escape*: ++
typeof: bool ++
default: false ++

View File

@ -170,6 +170,12 @@ auto waybar::modules::Custom::update() -> void {
if (label_.get_tooltip_markup() != str) {
label_.set_tooltip_markup(str);
}
} else if (config_["tooltip-format"].isString()) {
auto tooltip = config_["tooltip-format"].asString();
tooltip = fmt::format(fmt::runtime(tooltip), text_, fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_, alt_)),
fmt::arg("percentage", percentage_));
label_.set_tooltip_markup(tooltip);
} else {
if (label_.get_tooltip_markup() != tooltip_) {
label_.set_tooltip_markup(tooltip_);