mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(custon): restart_interval for continuous script
This commit is contained in:
parent
c3cdd516ef
commit
cb2f5c154c
@ -33,6 +33,12 @@ Addressed by *custom/<name>*
|
|||||||
You can update it manually with a signal. If no *interval* is defined,
|
You can update it manually with a signal. If no *interval* is defined,
|
||||||
it is assumed that the out script loops it self.
|
it is assumed that the out script loops it self.
|
||||||
|
|
||||||
|
*restart_interval*: ++
|
||||||
|
typeof: integer ++
|
||||||
|
The restart interval (in seconds).
|
||||||
|
Can't be used with the *interval* option, so only with continuous scripts.
|
||||||
|
Once the scripts exit, it'll be re-executed after the *restart_interval*.
|
||||||
|
|
||||||
*signal*: ++
|
*signal*: ++
|
||||||
typeof: integer ++
|
typeof: integer ++
|
||||||
The signal number used to update the module.
|
The signal number used to update the module.
|
||||||
|
@ -55,12 +55,21 @@ void waybar::modules::Custom::continuousWorker() {
|
|||||||
exit_code = WEXITSTATUS(util::command::close(fp_, pid_));
|
exit_code = WEXITSTATUS(util::command::close(fp_, pid_));
|
||||||
fp_ = nullptr;
|
fp_ = nullptr;
|
||||||
}
|
}
|
||||||
thread_.stop();
|
|
||||||
if (exit_code != 0) {
|
if (exit_code != 0) {
|
||||||
output_ = {exit_code, ""};
|
output_ = {exit_code, ""};
|
||||||
dp.emit();
|
dp.emit();
|
||||||
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
std::string output = buff;
|
std::string output = buff;
|
||||||
|
Loading…
Reference in New Issue
Block a user