marioortizmanero / polybar-pulseaudio-control

A feature-full Polybar module to control PulseAudio
MIT License
482 stars 50 forks source link

Is there a way to detect jack-plugged headphones? #52

Closed atcasanova closed 3 years ago

atcasanova commented 3 years ago

I can't find a way to detect it using pacmd

marioortizmanero commented 3 years ago

AFAIK the analog stereo output sink defaults to the jack when plugged in. On my machine it's called alsa_output.pci-0000_00_1b.0.analog-stereo, I think.

atcasanova commented 3 years ago

AFAIK the analog stereo output sink defaults to the jack when plugged in. On my machine it's called alsa_output.pci-0000_00_1b.0.analog-stereo, I think.

Yeah, i understood that. I guess i wasn't clear: I want to show an icon on polybar when the jack isn't plugged and another one when it is, but i can't find how

marioortizmanero commented 3 years ago

Ah okay. Have you tried with different ports? Run pactl list sinks when the jack is plugged in and when it isn't, and notice the Ports field. It will probably change in both runs. You can then use the IDs analog-output-.../port1 and analog-output-.../port2 to configure names for specific ports.

atcasanova commented 3 years ago

Thanks, it worked like a charm For anyone wondering: with headphones unplugged:

pacmd list-sinks | grep port ports: active port: <analog-output-speaker>

with headphones plugged: pacmd list-sinks | grep port ports: active port: <analog-output-headphones>

Polybar exec: pulseaudio-control --icons-volume " , , " --icon-muted " " --sink-nicknames-from "device.description" --sink-nickname "alsa_output.pci-0000_00_1f.3.analog-stereo/analog-output-speaker: " --sink-nickname "bluez_sink.70_26_05_CA_77_D2.a2dp_sink: " --sink-nickname "alsa_output.pci-0000_00_1f.3.analog-stereo/analog-output-headphones: " listen

marioortizmanero commented 3 years ago

Glad it worked! Thanks for sharing your solution :)