mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor: format code
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
#include "modules/clock.hpp"
|
||||
|
||||
waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "{:%H:%M}", 60)
|
||||
{
|
||||
: ALabel(config, "{:%H:%M}", 60) {
|
||||
label_.set_name("clock");
|
||||
if (!id.empty()) {
|
||||
label_.get_style_context()->add_class(id);
|
||||
@ -13,18 +12,20 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
|
||||
auto time_s = std::chrono::time_point_cast<std::chrono::seconds>(timeout);
|
||||
auto sub_m =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(time_s.time_since_epoch()).count() % interval_.count();
|
||||
if (sub_m > 0) thread_.sleep_until(timeout - std::chrono::seconds(sub_m - 1));
|
||||
else thread_.sleep_until(timeout - std::chrono::seconds(sub_m));
|
||||
std::chrono::duration_cast<std::chrono::seconds>(time_s.time_since_epoch()).count() %
|
||||
interval_.count();
|
||||
if (sub_m > 0)
|
||||
thread_.sleep_until(timeout - std::chrono::seconds(sub_m - 1));
|
||||
else
|
||||
thread_.sleep_until(timeout - std::chrono::seconds(sub_m));
|
||||
};
|
||||
}
|
||||
|
||||
auto waybar::modules::Clock::update() -> void
|
||||
{
|
||||
auto waybar::modules::Clock::update() -> void {
|
||||
auto localtime = fmt::localtime(std::time(nullptr));
|
||||
auto text = fmt::format(format_, localtime);
|
||||
label_.set_markup(text);
|
||||
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
auto tooltip_format = config_["tooltip-format"].asString();
|
||||
|
Reference in New Issue
Block a user