Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide/Unhide temperature module when "format*" is empty. #1485

Merged
merged 2 commits into from
Mar 19, 2022
Merged

Hide/Unhide temperature module when "format*" is empty. #1485

merged 2 commits into from
Mar 19, 2022

Conversation

LukashonakV
Copy link
Contributor

Actually even is set "format" : "" waybar displays some spaces. But when user wants to have the only notification when temperature threshold is triggered it looks not so good.
Current fix does:

  1. If nor "format" : "" neither "format-critical" : "" is defined - throw an exception in order to have temperature module disabled during the start process
  2. If "format" is empty and critical threshold is not triggered - hide the module

config example:

"temperature": {
        // "thermal-zone": 2,
        // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
        "format": "",
        "critical-threshold": 90,
        "format-critical": "<span font-family=\"Font Awesome 5 Free\">{icon}</span> {temperatureC}°C",
        "format-icons": ["", "", ""],
        "interval": 10
    },

Comment on lines 6 to 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();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that useful

Comment on lines 6 to 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();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that useful

Comment on lines 43 to 49
if(format.empty())
{
event_box_.hide();
return;
} else {
event_box_.show();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just lint and we'll be good :)

Comment on lines 43 to 49
if(format.empty())
{
event_box_.hide();
return;
} else {
event_box_.show();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just lint and we'll be good :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Please check the new one commit :)

@Alexays Alexays merged commit 8c6063d into Alexays:master Mar 19, 2022
@Alexays
Copy link
Owner

Alexays commented Mar 19, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants