I'm running XUbuntu 16.04. Previously I had speakers connected to analog line-out, and sound would automatically switch over to headphones when they were plugged in. This was all happening on one output device (motherboard audio).
I've now got a new monitor with built-in speakers, but no analog connection, so I'm getting audio over DisplayPort from my Radeon R9 270. I'd like pulseaudio to switch existing streams and new streams to the headphone port on the motherboard audio when I plug in the headphones, and back to the DP audio port on the GPU device when I unplug them again.
I've tried using
pactl load-module module-switch-on-connect, but it doesn't seem to have any effect, presumably because plugging in the headphones doesn't create a new sink, only a new port.
I know from reading other questions that I can do this manually with pactl/pacmd invocation and I'll do that if I have to, but I'd much prefer to have this happen automatically. I don't mind if I have to do some scripting to do it, but is there a hook I can intercept to get a call when the headphones are connected or disconnected?