Merge pull request #3395 from RobertMueller2/issue_33341
add hide-empty-text option to hide module whenever output is empty but format is not
This commit is contained in:
commit
93000e3fca
|
@ -21,6 +21,10 @@ Addressed by *custom/<name>*
|
||||||
The path to a script, which determines if the script in *exec* should be executed. ++
|
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.
|
*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*: ++
|
*exec-on-event*: ++
|
||||||
typeof: bool ++
|
typeof: bool ++
|
||||||
default: true ++
|
default: true ++
|
||||||
|
|
|
@ -162,7 +162,7 @@ auto waybar::modules::Custom::update() -> void {
|
||||||
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
|
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
|
||||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||||
fmt::arg("percentage", percentage_));
|
fmt::arg("percentage", percentage_));
|
||||||
if (str.empty()) {
|
if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) {
|
||||||
event_box_.hide();
|
event_box_.hide();
|
||||||
} else {
|
} else {
|
||||||
label_.set_markup(str);
|
label_.set_markup(str);
|
||||||
|
|
Loading…
Reference in New Issue