add check for tooltip-format for custom modules

This commit is contained in:
Josh Jones 2024-02-16 01:24:22 +01:00
parent 28cd9dff47
commit 9c3881f6f8
1 changed files with 6 additions and 0 deletions

View File

@ -170,6 +170,12 @@ auto waybar::modules::Custom::update() -> void {
if (label_.get_tooltip_markup() != str) { if (label_.get_tooltip_markup() != str) {
label_.set_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 { } else {
if (label_.get_tooltip_markup() != tooltip_) { if (label_.get_tooltip_markup() != tooltip_) {
label_.set_tooltip_markup(tooltip_); label_.set_tooltip_markup(tooltip_);