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