Use PA_PROP_DEVICE_FORM_FACTOR for device icon.

pull/550/head
PlusMinus0 2020-01-13 11:18:19 +01:00
parent b9cd51a9cc
commit 8fb3211594
2 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,7 @@ class Pulseaudio : public ALabel {
pa_cvolume pa_volume_; pa_cvolume pa_volume_;
bool muted_; bool muted_;
std::string port_name_; std::string port_name_;
std::string form_factor_;
std::string desc_; std::string desc_;
std::string monitor_; std::string monitor_;
// SOURCE // SOURCE

View File

@ -158,6 +158,9 @@ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_
pa->desc_ = i->description; pa->desc_ = i->description;
pa->monitor_ = i->monitor_source_name; pa->monitor_ = i->monitor_source_name;
pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown";
if (auto ff = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_FORM_FACTOR)) {
pa->form_factor_ = ff;
}
pa->dp.emit(); pa->dp.emit();
} }
} }
@ -185,7 +188,7 @@ static const std::array<std::string, 9> ports = {
}; };
const std::string waybar::modules::Pulseaudio::getPortIcon() const { const std::string waybar::modules::Pulseaudio::getPortIcon() const {
std::string nameLC = port_name_; std::string nameLC = port_name_ + form_factor_;
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) {