refactor(ALabel): add interval

This commit is contained in:
Alexis
2018-11-23 11:57:37 +01:00
parent 36652158ad
commit ad7400d5ce
10 changed files with 40 additions and 40 deletions

View File

@ -7,7 +7,7 @@ waybar::modules::Custom::Custom(const std::string name,
if (!config_["exec"].isString()) {
throw std::runtime_error(name_ + " has no exec path.");
}
if (config_["interval"].isUInt()) {
if (interval_.count() > 0) {
delayWorker();
} else {
continuousWorker();
@ -16,8 +16,7 @@ waybar::modules::Custom::Custom(const std::string name,
void waybar::modules::Custom::delayWorker()
{
auto interval = config_["interval"].asUInt();
thread_ = [this, interval] {
thread_ = [this] {
bool can_update = true;
if (config_["exec-if"].isString()) {
auto res = waybar::util::command::exec(config_["exec-if"].asString());
@ -31,7 +30,7 @@ void waybar::modules::Custom::delayWorker()
output_ = waybar::util::command::exec(config_["exec"].asString());
dp.emit();
}
thread_.sleep_for(chrono::seconds(interval));
thread_.sleep_for(interval_);
};
}