mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
custom: Fix "restart-interval"
This commit fixes the issue where the process would restart immediately and the thread would sleep after the process has restarted, and not before. Fixes #621
This commit is contained in:
parent
3c5fd4ba84
commit
ba78199dd1
@ -50,7 +50,6 @@ void waybar::modules::Custom::continuousWorker() {
|
|||||||
thread_ = [this, cmd] {
|
thread_ = [this, cmd] {
|
||||||
char* buff = nullptr;
|
char* buff = nullptr;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
bool restart = false;
|
|
||||||
if (getline(&buff, &len, fp_) == -1) {
|
if (getline(&buff, &len, fp_) == -1) {
|
||||||
int exit_code = 1;
|
int exit_code = 1;
|
||||||
if (fp_) {
|
if (fp_) {
|
||||||
@ -63,8 +62,8 @@ void waybar::modules::Custom::continuousWorker() {
|
|||||||
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
|
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
|
||||||
}
|
}
|
||||||
if (config_["restart-interval"].isUInt()) {
|
if (config_["restart-interval"].isUInt()) {
|
||||||
restart = true;
|
|
||||||
pid_ = -1;
|
pid_ = -1;
|
||||||
|
thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()));
|
||||||
fp_ = util::command::open(cmd, pid_);
|
fp_ = util::command::open(cmd, pid_);
|
||||||
if (!fp_) {
|
if (!fp_) {
|
||||||
throw std::runtime_error("Unable to open " + cmd);
|
throw std::runtime_error("Unable to open " + cmd);
|
||||||
@ -83,9 +82,6 @@ void waybar::modules::Custom::continuousWorker() {
|
|||||||
output_ = {0, output};
|
output_ = {0, output};
|
||||||
dp.emit();
|
dp.emit();
|
||||||
}
|
}
|
||||||
if (restart) {
|
|
||||||
thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user