Skip to content

Commit

Permalink
Merge pull request #3395 from RobertMueller2/issue_33341
Browse files Browse the repository at this point in the history
add hide-empty-text option to hide module whenever output is empty but format is not
  • Loading branch information
Alexays committed Jul 1, 2024
2 parents abfb654 + 8eee568 commit 93000e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions man/waybar-custom.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Addressed by *custom/<name>*
The path to a script, which determines if the script in *exec* should be executed. ++
*exec* will be executed if the exit code of *exec-if* equals 0.

*hide-empty-text*: ++
typeof: bool ++
Disables the module when output is empty, but format might contain additional static content.

*exec-on-event*: ++
typeof: bool ++
default: true ++
Expand Down
2 changes: 1 addition & 1 deletion src/modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ auto waybar::modules::Custom::update() -> void {
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_, alt_)),
fmt::arg("percentage", percentage_));
if (str.empty()) {
if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) {
event_box_.hide();
} else {
label_.set_markup(str);
Expand Down

0 comments on commit 93000e3

Please sign in to comment.