fix(Custom): loop script block main loop

This commit is contained in:
Alexis
2018-09-05 19:20:19 +02:00
parent 7020af7653
commit de5df09fcd
3 changed files with 7 additions and 7 deletions

View File

@ -24,6 +24,7 @@ void waybar::modules::Custom::worker()
}
}
if (can_update) {
output_ = waybar::util::command::exec(config_["exec"].asString());
dp.emit();
}
thread_.sleep_for(chrono::seconds(interval));
@ -32,17 +33,15 @@ void waybar::modules::Custom::worker()
auto waybar::modules::Custom::update() -> void
{
auto res = waybar::util::command::exec(config_["exec"].asString());
// Hide label if output is empty
if (res.out.empty() || res.exit_code != 0) {
if (output_.out.empty() || output_.exit_code != 0) {
label_.hide();
label_.set_name("");
} else {
label_.set_name("custom-" + name_);
auto str = fmt::format(format_, res.out);
auto str = fmt::format(format_, output_.out);
label_.set_text(str);
label_.set_tooltip_text(str);
label_.show();
}
}
}