feat(custon): restart_interval for continuous script

This commit is contained in:
Alex
2020-03-25 22:25:27 +01:00
parent c3cdd516ef
commit cb2f5c154c
2 changed files with 16 additions and 1 deletions

View File

@ -55,12 +55,21 @@ void waybar::modules::Custom::continuousWorker() {
exit_code = WEXITSTATUS(util::command::close(fp_, pid_));
fp_ = nullptr;
}
thread_.stop();
if (exit_code != 0) {
output_ = {exit_code, ""};
dp.emit();
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
}
if (config_["restart_interval"].isUInt()) {
pid_ = -1;
fp_ = util::command::open(cmd, pid_);
if (!fp_) {
throw std::runtime_error("Unable to open " + cmd);
}
thread_.sleep_for(std::chrono::seconds(config_["restart_interval"].asUInt());
} else {
thread_.stop();
}
return;
}
std::string output = buff;