feat(pulseaudio): add muted class

This commit is contained in:
Alexis 2018-08-10 00:02:50 +02:00
parent b85289f7ce
commit 291267711a
2 changed files with 10 additions and 1 deletions

View File

@ -59,3 +59,8 @@ window {
background: #f1c40f; background: #f1c40f;
color: black; color: black;
} }
.pulseaudio.muted {
background: #90b1b1;
color: #2a5c45;
}

View File

@ -100,9 +100,13 @@ void waybar::modules::Pulseaudio::_serverInfoCb(pa_context *context,
auto waybar::modules::Pulseaudio::update() -> void auto waybar::modules::Pulseaudio::update() -> void
{ {
auto format = _config["format"] ? _config["format"].asString() : "{}%"; auto format = _config["format"] ? _config["format"].asString() : "{}%";
if (_muted) if (_muted) {
format = format =
_config["format-muted"] ? _config["format-muted"].asString() : format; _config["format-muted"] ? _config["format-muted"].asString() : format;
if (!_label.get_style_context()->has_class("muted"))
_label.get_style_context()->add_class("muted");
} else if (_label.get_style_context()->has_class("muted"))
_label.get_style_context()->remove_class("muted");
_label.set_text(fmt::format(format, _volume)); _label.set_text(fmt::format(format, _volume));
} }