Merge pull request #1551 from loserMcloser/keyboard-state-css-classes

Add classes to individual keyboard state labels
This commit is contained in:
Alex 2022-05-12 13:55:32 +02:00 committed by GitHub
commit 9bc821bdac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 label*
- *#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) {
box_.set_name("keyboard-state");
if (config_["numlock"].asBool()) {
numlock_label_.get_style_context()->add_class("numlock");
box_.pack_end(numlock_label_, false, false, 0);
}
if (config_["capslock"].asBool()) {
capslock_label_.get_style_context()->add_class("capslock");
box_.pack_end(capslock_label_, false, false, 0);
}
if (config_["scrolllock"].asBool()) {
scrolllock_label_.get_style_context()->add_class("scrolllock");
box_.pack_end(scrolllock_label_, false, false, 0);
}
if (!id.empty()) {