Skip to content

Commit

Permalink
fix(custom): stop mixing manual and automatic arg indexing
Browse files Browse the repository at this point in the history
The current documentation for the custom module suggests mixing manual
(`{icon}`) and automatic (`{}`) indexing of format args. Newer versions
of the fmt library seem to not support this anymore (see issue #3605).

This commit introduces a name for the `text` output of the script, so
that `{text}` can now be used instead of `{}` in the configuration.
  • Loading branch information
lukasfink1 committed Sep 16, 2024
1 parent 9cfb1e3 commit 3bb3c2d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ auto waybar::modules::Custom::update() -> void {
parseOutputRaw();
}

auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
auto str = fmt::format(fmt::runtime(format_),
fmt::arg("text", text_),
fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_, alt_)),
fmt::arg("percentage", percentage_));
if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) {
Expand All @@ -169,7 +171,9 @@ auto waybar::modules::Custom::update() -> void {
if (tooltipEnabled()) {
if (tooltip_format_enabled_) {
auto tooltip = config_["tooltip-format"].asString();
tooltip = fmt::format(fmt::runtime(tooltip), text_, fmt::arg("alt", alt_),
tooltip = fmt::format(fmt::runtime(tooltip),
fmt::arg("text", text_),
fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_, alt_)),
fmt::arg("percentage", percentage_));
label_.set_tooltip_markup(tooltip);
Expand Down

0 comments on commit 3bb3c2d

Please sign in to comment.