MCPcopy Create free account
hub / github.com/Alexays/Waybar / update

Method update

src/modules/user.cpp:125–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125auto User::update() -> void {
126 std::string systemUser = this->get_user_login();
127 std::transform(systemUser.cbegin(), systemUser.cend(), systemUser.begin(),
128 [](unsigned char c) { return std::toupper(c); });
129
130 long uptimeSeconds = this->uptime_as_seconds();
131 auto workSystemTimeSeconds = std::chrono::seconds(uptimeSeconds);
132 auto currentSystemTime = std::chrono::system_clock::now();
133 auto startSystemTime = currentSystemTime - workSystemTimeSeconds;
134 long workSystemDays = uptimeSeconds / 86400;
135
136 auto label = fmt::format(
137 fmt::runtime(ALabel::format_), fmt::arg("up_H", fmt::format("{:%H}", startSystemTime)),
138 fmt::arg("up_M", fmt::format("{:%M}", startSystemTime)),
139 fmt::arg("up_d", fmt::format("{:%d}", startSystemTime)),
140 fmt::arg("up_m", fmt::format("{:%m}", startSystemTime)),
141 fmt::arg("up_Y", fmt::format("{:%Y}", startSystemTime)), fmt::arg("work_d", workSystemDays),
142 fmt::arg("work_H", fmt::format("{:%H}", workSystemTimeSeconds)),
143 fmt::arg("work_M", fmt::format("{:%M}", workSystemTimeSeconds)),
144 fmt::arg("work_S", fmt::format("{:%S}", workSystemTimeSeconds)),
145 fmt::arg("user", systemUser));
146 ALabel::label_.set_markup(label);
147 AIconLabel::update();
148}
149}; // namespace waybar::modules

Callers

nothing calls this directly

Calls 4

get_user_loginMethod · 0.95
uptime_as_secondsMethod · 0.95
formatFunction · 0.85
beginMethod · 0.45

Tested by

no test coverage detected