diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index ac85c4cc..8df3c4fc 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -8,13 +8,14 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) label_.get_style_context()->add_class(id); } thread_ = [this] { - auto now = std::chrono::system_clock::now(); dp.emit(); + auto now = std::chrono::system_clock::now(); auto timeout = std::chrono::floor(now + interval_); auto time_s = std::chrono::time_point_cast(timeout); auto sub_m = std::chrono::duration_cast(time_s.time_since_epoch()).count() % interval_.count(); - thread_.sleep_until(timeout - std::chrono::seconds(sub_m - 1)); + if (sub_m > 0) thread_.sleep_until(timeout - std::chrono::seconds(sub_m - 1)); + else thread_.sleep_until(timeout - std::chrono::seconds(sub_m)); }; }