2018-08-08 21:54:58 +00:00
|
|
|
#include "modules/clock.hpp"
|
|
|
|
|
|
|
|
waybar::modules::Clock::Clock()
|
|
|
|
{
|
2018-08-09 08:50:16 +00:00
|
|
|
_label.get_style_context()->add_class("clock");
|
2018-08-08 21:54:58 +00:00
|
|
|
_thread = [this] {
|
|
|
|
auto now = waybar::chrono::clock::now();
|
|
|
|
auto t = std::time(nullptr);
|
|
|
|
auto localtime = std::localtime(&t);
|
|
|
|
_label.set_text(
|
|
|
|
fmt::format("{:02}:{:02}", localtime->tm_hour, localtime->tm_min));
|
|
|
|
auto timeout =
|
|
|
|
std::chrono::floor<std::chrono::minutes>(now + std::chrono::minutes(1));
|
|
|
|
_thread.sleep_until(timeout);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
waybar::modules::Clock::operator Gtk::Widget &() {
|
|
|
|
return _label;
|
|
|
|
}
|