Skip to content

Commit

Permalink
Support muted icons for pulseaudio devices/ports
Browse files Browse the repository at this point in the history
  • Loading branch information
locked-out committed Jun 12, 2024
1 parent 0251e25 commit 892042e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/modules/pulseaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,27 @@ static const std::array<std::string, 9> ports = {
};

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::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;
}

Expand Down

0 comments on commit 892042e

Please sign in to comment.