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

Method update

src/modules/jack.cpp:53–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53auto JACK::update() -> void {
54 std::string format;
55 std::string state = JACKState();
56 float latency = 1000 * (float)bufsize_ / (float)samplerate_;
57
58 if (label_.get_style_context()->has_class("xrun")) {
59 label_.get_style_context()->remove_class("xrun");
60 state = "connected";
61 }
62
63 if (label_.get_style_context()->has_class(state_))
64 label_.get_style_context()->remove_class(state_);
65 label_.get_style_context()->add_class(state);
66 state_ = state;
67
68 if (config_["format-" + state].isString()) {
69 format = config_["format-" + state].asString();
70 } else if (config_["format"].isString()) {
71 format = config_["format"].asString();
72 } else
73 format = "{load}%";
74
75 label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("load", std::round(load_)),
76 fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
77 fmt::arg("latency", fmt::format("{:.2f}", latency)),
78 fmt::arg("xruns", xruns_)));
79
80 if (tooltipEnabled()) {
81 std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms";
82 if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString();
83 label_.set_tooltip_text(fmt::format(
84 fmt::runtime(tooltip_format), fmt::arg("load", std::round(load_)),
85 fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
86 fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_)));
87 }
88
89 // Call parent update
90 ALabel::update();
91}
92
93int JACK::bufSize(jack_nframes_t size) {
94 bufsize_ = size;

Callers

nothing calls this directly

Calls 1

formatFunction · 0.85

Tested by

no test coverage detected