Merge pull request #3353 from locked-out/muted_icons
Support for muted icons for pulseaudio devices/ports
This commit is contained in:
commit
79a6229522
|
@ -142,6 +142,8 @@ If they are found in the current PulseAudio port name, the corresponding icons w
|
||||||
- *hifi*
|
- *hifi*
|
||||||
- *phone*
|
- *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
|
# EXAMPLES
|
||||||
|
|
||||||
|
@ -152,10 +154,12 @@ If they are found in the current PulseAudio port name, the corresponding icons w
|
||||||
"format-muted": "",
|
"format-muted": "",
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
"alsa_output.pci-0000_00_1f.3.analog-stereo": "",
|
"alsa_output.pci-0000_00_1f.3.analog-stereo": "",
|
||||||
|
"alsa_output.pci-0000_00_1f.3.analog-stereo-muted": "",
|
||||||
"headphones": "",
|
"headphones": "",
|
||||||
"handsfree": "",
|
"handsfree": "",
|
||||||
"headset": "",
|
"headset": "",
|
||||||
"phone": "",
|
"phone": "",
|
||||||
|
"phone-muted": "",
|
||||||
"portable": "",
|
"portable": "",
|
||||||
"car": "",
|
"car": "",
|
||||||
"default": ["", ""]
|
"default": ["", ""]
|
||||||
|
|
|
@ -42,14 +42,26 @@ static const std::array<std::string, 9> ports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const {
|
const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const {
|
||||||
std::vector<std::string> res = {backend->getCurrentSinkName(), backend->getDefaultSourceName()};
|
std::vector<std::string> 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::string nameLC = backend->getSinkPortName() + backend->getFormFactor();
|
||||||
std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower);
|
std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower);
|
||||||
for (auto const &port : ports) {
|
for (auto const &port : ports) {
|
||||||
if (nameLC.find(port) != std::string::npos) {
|
if (nameLC.find(port) != std::string::npos) {
|
||||||
res.push_back(port);
|
if (sink_muted) {
|
||||||
return res;
|
res.emplace_back(port + "-muted");
|
||||||
}
|
}
|
||||||
|
res.push_back(port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sink_muted) {
|
||||||
|
res.emplace_back("default-muted");
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue