feat(clock): allow choose interval
parent
608b791ac1
commit
008856cbb8
|
@ -4,11 +4,12 @@ waybar::modules::Clock::Clock(Json::Value config)
|
||||||
: _config(config)
|
: _config(config)
|
||||||
{
|
{
|
||||||
_label.set_name("clock");
|
_label.set_name("clock");
|
||||||
_thread = [this] {
|
int interval = _config["interval"] ? _config["inveral"].asInt() : 60;
|
||||||
Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Clock::update));
|
_thread = [this, interval] {
|
||||||
auto now = waybar::chrono::clock::now();
|
auto now = waybar::chrono::clock::now();
|
||||||
auto timeout =
|
Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Clock::update));
|
||||||
std::chrono::floor<std::chrono::minutes>(now + std::chrono::minutes(1));
|
auto timeout = std::chrono::floor<std::chrono::seconds>(now
|
||||||
|
+ std::chrono::seconds(interval));
|
||||||
_thread.sleep_until(timeout);
|
_thread.sleep_until(timeout);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue