Merge remote-tracking branch 'origin/mig-D' into refactor/generic-tooltip
This commit is contained in:
+4
-13
@@ -72,19 +72,10 @@ auto JACK::update() -> void {
|
||||
} else
|
||||
format = "{load}%";
|
||||
|
||||
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("load", std::round(load_)),
|
||||
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
||||
fmt::arg("latency", fmt::format("{:.2f}", latency)),
|
||||
fmt::arg("xruns", xruns_)));
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms";
|
||||
if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString();
|
||||
label_.set_tooltip_markup(fmt::format(
|
||||
fmt::runtime(tooltip_format), fmt::arg("load", std::round(load_)),
|
||||
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
||||
fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_)));
|
||||
}
|
||||
updateLabelAndTooltip(
|
||||
format, "{bufsize}/{samplerate} {latency}ms", fmt::arg("load", std::round(load_)),
|
||||
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
||||
fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_));
|
||||
|
||||
// Call parent update
|
||||
ALabel::update();
|
||||
|
||||
+41
-54
@@ -350,32 +350,45 @@ auto waybar::modules::Network::update() -> void {
|
||||
final_ipaddr_ += ipaddr6_;
|
||||
}
|
||||
|
||||
auto text = fmt::format(
|
||||
fmt::runtime(format_), fmt::arg("essid", essid_), fmt::arg("bssid", bssid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_), fmt::arg("signalStrength", signal_strength_),
|
||||
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
||||
fmt::arg("netmask", netmask_), fmt::arg("netmask6", netmask6_),
|
||||
fmt::arg("ipaddr", final_ipaddr_), fmt::arg("gwaddr", gwaddr_), fmt::arg("cidr", cidr_),
|
||||
fmt::arg("cidr6", cidr6_), fmt::arg("frequency", fmt::format("{:.1f}", frequency_)),
|
||||
fmt::arg("icon", getIcon(signal_strength_, state_)),
|
||||
fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("essid", essid_));
|
||||
store.push_back(fmt::arg("bssid", bssid_));
|
||||
store.push_back(fmt::arg("signaldBm", signal_strength_dbm_));
|
||||
store.push_back(fmt::arg("signalStrength", signal_strength_));
|
||||
store.push_back(fmt::arg("signalStrengthApp", signal_strength_app_));
|
||||
store.push_back(fmt::arg("ifname", ifname_));
|
||||
store.push_back(fmt::arg("netmask", netmask_));
|
||||
store.push_back(fmt::arg("netmask6", netmask6_));
|
||||
store.push_back(fmt::arg("ipaddr", final_ipaddr_));
|
||||
store.push_back(fmt::arg("gwaddr", gwaddr_));
|
||||
store.push_back(fmt::arg("cidr", cidr_));
|
||||
store.push_back(fmt::arg("cidr6", cidr6_));
|
||||
store.push_back(fmt::arg("frequency", fmt::format("{:.1f}", frequency_)));
|
||||
store.push_back(fmt::arg("icon", getIcon(signal_strength_, state_)));
|
||||
store.push_back(
|
||||
fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / elapsed_seconds, "b/s")));
|
||||
store.push_back(
|
||||
fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / elapsed_seconds, "b/s")));
|
||||
store.push_back(
|
||||
fmt::arg("bandwidthTotalBits",
|
||||
pow_format((bandwidth_up + bandwidth_down) * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthTotalOctets",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / elapsed_seconds, "B/s")),
|
||||
fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / elapsed_seconds, "B/s")),
|
||||
fmt::arg("bandwidthDownBytesCompact",
|
||||
pow_format(bandwidth_down / elapsed_seconds, "B", false, 2)),
|
||||
fmt::arg("bandwidthUpBytesCompact",
|
||||
pow_format(bandwidth_up / elapsed_seconds, "B", false, 2)),
|
||||
fmt::arg("bandwidthTotalBytes",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "B/s")));
|
||||
if (text.compare(label_.get_label()) != 0) {
|
||||
label_.set_markup(text);
|
||||
pow_format((bandwidth_up + bandwidth_down) * 8ull / elapsed_seconds, "b/s")));
|
||||
store.push_back(
|
||||
fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / elapsed_seconds, "o/s")));
|
||||
store.push_back(fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / elapsed_seconds, "o/s")));
|
||||
store.push_back(fmt::arg("bandwidthTotalOctets",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "o/s")));
|
||||
store.push_back(
|
||||
fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / elapsed_seconds, "B/s")));
|
||||
store.push_back(fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / elapsed_seconds, "B/s")));
|
||||
store.push_back(fmt::arg("bandwidthDownBytesCompact",
|
||||
pow_format(bandwidth_down / elapsed_seconds, "B", false, 2)));
|
||||
store.push_back(fmt::arg("bandwidthUpBytesCompact",
|
||||
pow_format(bandwidth_up / elapsed_seconds, "B", false, 2)));
|
||||
store.push_back(fmt::arg("bandwidthTotalBytes",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "B/s")));
|
||||
|
||||
auto text = fmt::vformat(format_, store);
|
||||
if (setLabelMarkup(text)) {
|
||||
if (text.empty()) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
@@ -387,35 +400,9 @@ auto waybar::modules::Network::update() -> void {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
if (!tooltip_format.empty()) {
|
||||
auto tooltip_text = fmt::format(
|
||||
fmt::runtime(tooltip_format), fmt::arg("essid", essid_), fmt::arg("bssid", bssid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_), fmt::arg("signalStrength", signal_strength_),
|
||||
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
||||
fmt::arg("netmask", netmask_), fmt::arg("netmask6", netmask6_),
|
||||
fmt::arg("ipaddr", final_ipaddr_), fmt::arg("gwaddr", gwaddr_), fmt::arg("cidr", cidr_),
|
||||
fmt::arg("cidr6", cidr6_), fmt::arg("frequency", fmt::format("{:.1f}", frequency_)),
|
||||
fmt::arg("icon", getIcon(signal_strength_, state_)),
|
||||
fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::arg("bandwidthTotalBits",
|
||||
pow_format((bandwidth_up + bandwidth_down) * 8ull / elapsed_seconds, "b/s")),
|
||||
fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthTotalOctets",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "o/s")),
|
||||
fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / elapsed_seconds, "B/s")),
|
||||
fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / elapsed_seconds, "B/s")),
|
||||
fmt::arg("bandwidthDownBytesCompact",
|
||||
pow_format(bandwidth_down / elapsed_seconds, "B", false, 2)),
|
||||
fmt::arg("bandwidthUpBytesCompact",
|
||||
pow_format(bandwidth_up / elapsed_seconds, "B", false, 2)),
|
||||
fmt::arg("bandwidthTotalBytes",
|
||||
pow_format((bandwidth_up + bandwidth_down) / elapsed_seconds, "B/s")));
|
||||
if (label_.get_tooltip_text() != tooltip_text) {
|
||||
label_.set_tooltip_markup(tooltip_text);
|
||||
}
|
||||
} else if (label_.get_tooltip_text() != text) {
|
||||
label_.set_tooltip_markup(text);
|
||||
setTooltipMarkup(fmt::vformat(tooltip_format, store));
|
||||
} else {
|
||||
setTooltipMarkup(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,18 +187,14 @@ void PowerProfilesDaemon::switchToProfile(std::string const& str) {
|
||||
auto PowerProfilesDaemon::update() -> void {
|
||||
if (connected_ && activeProfile_ != availableProfiles_.end()) {
|
||||
auto profile = (*activeProfile_);
|
||||
// Set label
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("profile", profile.name));
|
||||
// Legacy placeholder, kept for backward compatibility with existing configs.
|
||||
store.push_back(fmt::arg("driver", profile.driver));
|
||||
store.push_back(fmt::arg("cpu_driver", profile.cpuDriver));
|
||||
store.push_back(fmt::arg("platform_driver", profile.platformDriver));
|
||||
store.push_back(fmt::arg("icon", getIcon(0, profile.name)));
|
||||
label_.set_markup(fmt::vformat(format_, store));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_markup(fmt::vformat(tooltipFormat_, store));
|
||||
}
|
||||
// Set label and tooltip
|
||||
updateLabelAndTooltip(format_, tooltipFormat_, fmt::arg("profile", profile.name),
|
||||
// Legacy placeholder, kept for backward compatibility with existing
|
||||
// configs.
|
||||
fmt::arg("driver", profile.driver),
|
||||
fmt::arg("cpu_driver", profile.cpuDriver),
|
||||
fmt::arg("platform_driver", profile.platformDriver),
|
||||
fmt::arg("icon", getIcon(0, profile.name)));
|
||||
|
||||
// Set CSS class
|
||||
if (!currentStyle_.empty()) {
|
||||
|
||||
+14
-15
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-23
@@ -432,7 +432,6 @@ void waybar::modules::Wireplumber::asyncLoadRequiredApiModules() {
|
||||
|
||||
auto waybar::modules::Wireplumber::update() -> void {
|
||||
auto format = format_;
|
||||
std::string tooltipFormat;
|
||||
|
||||
// Handle sink mute state
|
||||
if (muted_) {
|
||||
@@ -486,32 +485,28 @@ auto waybar::modules::Wireplumber::update() -> void {
|
||||
std::string formatted_source =
|
||||
fmt::format(fmt::runtime(format_source), fmt::arg("volume", source_vol));
|
||||
|
||||
std::string markup =
|
||||
fmt::format(fmt::runtime(format), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
||||
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
||||
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_),
|
||||
fmt::arg("volume_linear", volume_), fmt::arg("volume_cubic", vol_cube),
|
||||
fmt::arg("volume_db", vol_db), fmt::arg("source_volume_linear", source_volume_),
|
||||
fmt::arg("source_volume_cubic", source_vol_cube),
|
||||
fmt::arg("source_volume_db", source_vol_db));
|
||||
label_.set_markup(markup);
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("node_name", node_name_));
|
||||
store.push_back(fmt::arg("volume", vol));
|
||||
store.push_back(fmt::arg("icon", getIcon(vol)));
|
||||
store.push_back(fmt::arg("format_source", formatted_source));
|
||||
store.push_back(fmt::arg("source_volume", source_vol));
|
||||
store.push_back(fmt::arg("source_desc", source_name_));
|
||||
store.push_back(fmt::arg("volume_linear", volume_));
|
||||
store.push_back(fmt::arg("volume_cubic", vol_cube));
|
||||
store.push_back(fmt::arg("volume_db", vol_db));
|
||||
store.push_back(fmt::arg("source_volume_linear", source_volume_));
|
||||
store.push_back(fmt::arg("source_volume_cubic", source_vol_cube));
|
||||
store.push_back(fmt::arg("source_volume_db", source_vol_db));
|
||||
|
||||
setLabelMarkup(fmt::vformat(format, store));
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
if (tooltipFormat.empty() && config_["tooltip-format"].isString()) {
|
||||
tooltipFormat = config_["tooltip-format"].asString();
|
||||
}
|
||||
|
||||
auto tooltipFormat = resolveTooltipFormat("");
|
||||
if (!tooltipFormat.empty()) {
|
||||
label_.set_tooltip_markup(fmt::format(
|
||||
fmt::runtime(tooltipFormat), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
||||
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
||||
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_),
|
||||
fmt::arg("volume_linear", volume_), fmt::arg("volume_cubic", vol_cube),
|
||||
fmt::arg("volume_db", vol_db), fmt::arg("source_volume_linear", source_volume_),
|
||||
fmt::arg("source_volume_cubic", source_vol_cube),
|
||||
fmt::arg("source_volume_db", source_vol_db)));
|
||||
setTooltipMarkup(fmt::vformat(tooltipFormat, store));
|
||||
} else {
|
||||
label_.set_tooltip_markup(node_name_);
|
||||
setTooltipMarkup(node_name_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user