Add style class for CPU state
Fixes: https://github.com/Alexays/Waybar/issues/2911
This commit is contained in:
parent
2c244b5e83
commit
a0bac34329
|
@ -22,6 +22,7 @@ class Cpu : public ALabel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::tuple<size_t, size_t>> prev_times_;
|
std::vector<std::tuple<size_t, size_t>> prev_times_;
|
||||||
|
std::string prev_state_;
|
||||||
|
|
||||||
util::SleeperThread thread_;
|
util::SleeperThread thread_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -121,3 +121,5 @@ CPU usage per core rendered as icons:
|
||||||
# STYLE
|
# STYLE
|
||||||
|
|
||||||
- *#cpu*
|
- *#cpu*
|
||||||
|
- *#cpu.<state>*
|
||||||
|
- *<state>* can be defined in the *config*. For more information see *states*.
|
||||||
|
|
|
@ -36,6 +36,12 @@ auto waybar::modules::Cpu::update() -> void {
|
||||||
format = config_["format-" + state].asString();
|
format = config_["format-" + state].asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!prev_state_.empty()) {
|
||||||
|
label_.get_style_context()->remove_class(prev_state_);
|
||||||
|
}
|
||||||
|
label_.get_style_context()->add_class(state);
|
||||||
|
prev_state_ = state;
|
||||||
|
|
||||||
if (format.empty()) {
|
if (format.empty()) {
|
||||||
event_box_.hide();
|
event_box_.hide();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue