From 892042eb92f9b95736930298bf07ff02ebfaded9 Mon Sep 17 00:00:00 2001 From: Oliver Locke Date: Wed, 12 Jun 2024 17:03:39 +1000 Subject: [PATCH 1/2] Support muted icons for pulseaudio devices/ports --- src/modules/pulseaudio.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index d7dc80d36..3efd9d232 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -42,15 +42,27 @@ static const std::array ports = { }; const std::vector waybar::modules::Pulseaudio::getPulseIcon() const { - std::vector res = {backend->getCurrentSinkName(), backend->getDefaultSourceName()}; + std::vector res; + auto sink_muted = backend->getSinkMuted(); + if (sink_muted) { + res.emplace_back(backend->getCurrentSinkName() + "-muted"); + } + res.push_back(backend->getCurrentSinkName()); + res.push_back(backend->getDefaultSourceName()); std::string nameLC = backend->getSinkPortName() + backend->getFormFactor(); std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower); for (auto const &port : ports) { if (nameLC.find(port) != std::string::npos) { + if (sink_muted) { + res.emplace_back(port + "-muted"); + } res.push_back(port); - return res; + break; } } + if (sink_muted) { + res.emplace_back("default-muted"); + } return res; } From 01438f71a489f5a755f215c203cd73c0c7fe20d3 Mon Sep 17 00:00:00 2001 From: Oliver Locke Date: Thu, 13 Jun 2024 15:59:42 +1000 Subject: [PATCH 2/2] Added muted icons usage to waybar-pulseaudio man page --- man/waybar-pulseaudio.5.scd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index 4bc75258f..6a29e8fcf 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -142,6 +142,8 @@ If they are found in the current PulseAudio port name, the corresponding icons w - *hifi* - *phone* +Additionally, suffixing a device name or port with *-muted* will cause the icon +to be selected when the corresponding audio device is muted. This applies to *default* as well. # EXAMPLES @@ -152,10 +154,12 @@ If they are found in the current PulseAudio port name, the corresponding icons w "format-muted": "", "format-icons": { "alsa_output.pci-0000_00_1f.3.analog-stereo": "", + "alsa_output.pci-0000_00_1f.3.analog-stereo-muted": "", "headphones": "", "handsfree": "", "headset": "", "phone": "", + "phone-muted": "", "portable": "", "car": "", "default": ["", ""]