From 9f337db2d2d75f91c1d1ba73fabb01c5a020ed04 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Wed, 16 Mar 2022 15:50:00 +0300 Subject: [PATCH 1/3] Hide/Unhide module when "format*" is empty. --- src/modules/temperature.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 84560e8d..86aea70a 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -3,6 +3,11 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config) : ALabel(config, "temperature", id, "{temperatureC}°C", 10) { + if (config_["format"].asString().empty() && config_["format-critical"].asString().empty()) { + throw std::runtime_error("Format configuration is not defined"); + } else if (config_["format"].asString().empty()) { + format_.clear(); + } if (config_["hwmon-path"].isString()) { file_path_ = config_["hwmon-path"].asString(); } else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) { @@ -34,6 +39,15 @@ auto waybar::modules::Temperature::update() -> void { } else { label_.get_style_context()->remove_class("critical"); } + + if(format.empty()) + { + event_box_.hide(); + return; + } else { + event_box_.show(); + } + auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0; label_.set_markup(fmt::format(format, fmt::arg("temperatureC", temperature_c), From 6946288053e5d32731e65ac88289f99d5a2f1080 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Thu, 17 Mar 2022 11:31:06 +0300 Subject: [PATCH 2/3] PR #1485 review --- src/modules/temperature.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 86aea70a..627ece90 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -3,11 +3,6 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config) : ALabel(config, "temperature", id, "{temperatureC}°C", 10) { - if (config_["format"].asString().empty() && config_["format-critical"].asString().empty()) { - throw std::runtime_error("Format configuration is not defined"); - } else if (config_["format"].asString().empty()) { - format_.clear(); - } if (config_["hwmon-path"].isString()) { file_path_ = config_["hwmon-path"].asString(); } else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) { @@ -40,8 +35,7 @@ auto waybar::modules::Temperature::update() -> void { label_.get_style_context()->remove_class("critical"); } - if(format.empty()) - { + if(format.empty()) { event_box_.hide(); return; } else { From fcf93a6c45eede8fb5a31e6a1c0613f368e09ecc Mon Sep 17 00:00:00 2001 From: momokrono Date: Fri, 18 Mar 2022 10:35:19 +0100 Subject: [PATCH 3/3] feat: added network speed in Bytes --- src/modules/network.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 6935430e..74b54d91 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -342,7 +342,9 @@ auto waybar::modules::Network::update() -> void { fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / interval_.count(), "b/s")), fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / interval_.count(), "b/s")), fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / interval_.count(), "o/s")), - fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s"))); + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s")), + fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / interval_.count(), "B/s")), + fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s"))); if (text.compare(label_.get_label()) != 0) { label_.set_markup(text); if (text.empty()) { @@ -373,7 +375,9 @@ auto waybar::modules::Network::update() -> void { pow_format(bandwidth_down * 8ull / interval_.count(), "b/s")), fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / interval_.count(), "b/s")), fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / interval_.count(), "o/s")), - fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s"))); + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s")), + fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / interval_.count(), "B/s")), + fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s"))); if (label_.get_tooltip_text() != tooltip_text) { label_.set_tooltip_text(tooltip_text); }