mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-20 01:42:38 +02:00
Issue 1226/1497: align updates with times divisible by interval
This commit is contained in:
@@ -74,7 +74,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
|||||||
|
|
||||||
thread_ = [this] {
|
thread_ = [this] {
|
||||||
dp.emit();
|
dp.emit();
|
||||||
thread_.sleep_for(interval_);
|
auto now = std::chrono::system_clock::now();
|
||||||
|
/* difference with projected wakeup time */
|
||||||
|
auto diff = now.time_since_epoch() % interval_;
|
||||||
|
/* sleep until the next projected time */
|
||||||
|
thread_.sleep_for(interval_ - diff);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
|||||||
: ALabel(config, "clock", id, "{:%H:%M}", 60) {
|
: ALabel(config, "clock", id, "{:%H:%M}", 60) {
|
||||||
thread_ = [this] {
|
thread_ = [this] {
|
||||||
dp.emit();
|
dp.emit();
|
||||||
thread_.sleep_for(interval_);
|
auto now = std::chrono::system_clock::now();
|
||||||
|
/* difference with projected wakeup time */
|
||||||
|
auto diff = now.time_since_epoch() % interval_;
|
||||||
|
/* sleep until the next projected time */
|
||||||
|
thread_.sleep_for(interval_ - diff);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user