refactor(modules): migrate audio/network/power modules to ALabel tooltip helpers

Migrate network, pulseaudio, wireplumber, jack and power_profiles_daemon
to the generic ALabel tooltip helpers:

- jack and power-profiles-daemon use updateLabelAndTooltip() since their
  label/tooltip share a single arg set and a format-string tooltip default.
- network, pulseaudio and wireplumber keep their rich in-module format
  selection but build a single fmt arg store, render the label/tooltip
  through the dedup-aware setLabelMarkup()/setTooltipMarkup() setters and
  resolveTooltipFormat(), preserving their custom fallbacks (label text,
  sink/node description) and visibility handling exactly.
This commit is contained in:
Alex
2026-07-04 00:04:47 +02:00
parent a91dcbe595
commit 014c95a9fe
5 changed files with 85 additions and 117 deletions
+14 -15
View File
@@ -72,7 +72,6 @@ const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const
auto waybar::modules::Pulseaudio::update() -> void {
auto format = format_;
std::string tooltip_format;
auto sink_volume = backend->getSinkVolume();
if (!alt_) {
std::string format_name = "format";
@@ -120,29 +119,29 @@ auto waybar::modules::Pulseaudio::update() -> void {
auto source_desc = backend->getSourceDesc();
format_source = fmt::format(fmt::runtime(format_source), fmt::arg("volume", source_volume));
auto text = fmt::format(
fmt::runtime(format), fmt::arg("desc", sink_desc), fmt::arg("volume", sink_volume),
fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume),
fmt::arg("source_desc", source_desc), fmt::arg("icon", getIcon(sink_volume, getPulseIcon())));
fmt::dynamic_format_arg_store<fmt::format_context> store;
store.push_back(fmt::arg("desc", sink_desc));
store.push_back(fmt::arg("volume", sink_volume));
store.push_back(fmt::arg("format_source", format_source));
store.push_back(fmt::arg("source_volume", source_volume));
store.push_back(fmt::arg("source_desc", source_desc));
store.push_back(fmt::arg("icon", getIcon(sink_volume, getPulseIcon())));
auto text = fmt::vformat(format, store);
if (text.empty()) {
label_.hide();
} else {
label_.set_markup(text);
setLabelMarkup(text);
label_.show();
}
if (tooltipEnabled()) {
if (tooltip_format.empty() && config_["tooltip-format"].isString()) {
tooltip_format = config_["tooltip-format"].asString();
}
auto tooltip_format = resolveTooltipFormat("");
if (!tooltip_format.empty()) {
label_.set_tooltip_markup(fmt::format(
fmt::runtime(tooltip_format), fmt::arg("desc", sink_desc),
fmt::arg("volume", sink_volume), fmt::arg("format_source", format_source),
fmt::arg("source_volume", source_volume), fmt::arg("source_desc", source_desc),
fmt::arg("icon", getIcon(sink_volume, getPulseIcon()))));
setTooltipMarkup(fmt::vformat(tooltip_format, store));
} else {
label_.set_tooltip_markup(sink_desc);
setTooltipMarkup(sink_desc);
}
}