Skip to content

Commit

Permalink
Merge pull request #2923 from jones-josh/custom-tooltip-format
Browse files Browse the repository at this point in the history
Add check for tooltip-format for custom modules
  • Loading branch information
Alexays authored Feb 19, 2024
2 parents a18b6dc + 7f3e396 commit 9191cae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions man/waybar-custom.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++
Expand Down
6 changes: 6 additions & 0 deletions src/modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down

0 comments on commit 9191cae

Please sign in to comment.