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

Method getText

src/modules/upower.cpp:419–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417}
418
419const Glib::ustring UPower::getText(const upDevice_output& upDevice_, const std::string& format) {
420 Glib::ustring ret{""};
421 if (upDevice_.upDevice != NULL) {
422 std::string timeStr{""};
423 switch (upDevice_.state) {
424 case UP_DEVICE_STATE_CHARGING:
425 case UP_DEVICE_STATE_PENDING_CHARGE:
426 timeStr = secondsToString(std::chrono::seconds(upDevice_.time_full));
427 break;
428 case UP_DEVICE_STATE_DISCHARGING:
429 case UP_DEVICE_STATE_PENDING_DISCHARGE:
430 timeStr = secondsToString(std::chrono::seconds(upDevice_.time_empty));
431 break;
432 default:
433 break;
434 }
435
436 ret = fmt::format(
437 fmt::runtime(format),
438 fmt::arg("percentage", std::to_string((int)std::round(upDevice_.percentage)) + '%'),
439 fmt::arg("time", timeStr),
440 fmt::arg("temperature", fmt::format("{:-.2g}C", upDevice_.temperature)),
441 fmt::arg("model", upDevice_.model), fmt::arg("native-path", upDevice_.nativePath));
442 }
443
444 return ret;
445}
446
447bool UPower::queryTooltipCb(int x, int y, bool keyboard_tooltip,
448 const Glib::RefPtr<Gtk::Tooltip>& tooltip) {

Callers

nothing calls this directly

Calls 3

secondsToStringFunction · 0.85
formatFunction · 0.85
to_stringFunction · 0.85

Tested by

no test coverage detected