Skip to content

Commit 9f337db

Browse files
committed
Hide/Unhide module when "format*" is empty.
1 parent a37ef74 commit 9f337db

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/modules/temperature.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
55
: ALabel(config, "temperature", id, "{temperatureC}°C", 10) {
6+
if (config_["format"].asString().empty() && config_["format-critical"].asString().empty()) {
7+
throw std::runtime_error("Format configuration is not defined");
8+
} else if (config_["format"].asString().empty()) {
9+
format_.clear();
10+
}
611
if (config_["hwmon-path"].isString()) {
712
file_path_ = config_["hwmon-path"].asString();
813
} else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) {
@@ -34,6 +39,15 @@ auto waybar::modules::Temperature::update() -> void {
3439
} else {
3540
label_.get_style_context()->remove_class("critical");
3641
}
42+
43+
if(format.empty())
44+
{
45+
event_box_.hide();
46+
return;
47+
} else {
48+
event_box_.show();
49+
}
50+
3751
auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0;
3852
label_.set_markup(fmt::format(format,
3953
fmt::arg("temperatureC", temperature_c),

0 commit comments

Comments
 (0)