Add classes to individual keyboard state labels

pull/1551/head
loserMcloser 2022-05-11 00:44:57 -06:00 committed by Jeremy Sylvestre
parent 4592dd4a6c
commit bfcb936d87
2 changed files with 9 additions and 1 deletions

View File

@ -79,4 +79,9 @@ The following *format-icons* can be set.
- *#keyboard-state* - *#keyboard-state*
- *#keyboard-state label* - *#keyboard-state label*
- *#keyboard-state label.locked* - *#keyboard-state label.locked*
- *#keyboard-state label.numlock*
- *#keyboard-state label.numlock.locked*
- *#keyboard-state label.capslock*
- *#keyboard-state label.capslock.locked*
- *#keyboard-state label.scrolllock*
- *#keyboard-state label.scrolllock.locked*

View File

@ -103,12 +103,15 @@ waybar::modules::KeyboardState::KeyboardState(const std::string& id, const Bar&
dev_(nullptr) { dev_(nullptr) {
box_.set_name("keyboard-state"); box_.set_name("keyboard-state");
if (config_["numlock"].asBool()) { if (config_["numlock"].asBool()) {
numlock_label_.get_style_context()->add_class("numlock");
box_.pack_end(numlock_label_, false, false, 0); box_.pack_end(numlock_label_, false, false, 0);
} }
if (config_["capslock"].asBool()) { if (config_["capslock"].asBool()) {
capslock_label_.get_style_context()->add_class("capslock");
box_.pack_end(capslock_label_, false, false, 0); box_.pack_end(capslock_label_, false, false, 0);
} }
if (config_["scrolllock"].asBool()) { if (config_["scrolllock"].asBool()) {
scrolllock_label_.get_style_context()->add_class("scrolllock");
box_.pack_end(scrolllock_label_, false, false, 0); box_.pack_end(scrolllock_label_, false, false, 0);
} }
if (!id.empty()) { if (!id.empty()) {