Switch audio profile when plugging/unplugging 3.5mm jack

I am using Ubuntu 25.04, I installed kubuntu originally but I am running a sway desktop.

I had an audio problem earlier which I can now solve manually, but I would like to make it automatic.

That is, I would like to switch the sound profile to “… headphones …” (see attached screenshot) whenever something is plugged into the 3.5mm jack plug of the laptop, and back to “… speaker …” if it is unplugged.

I am running pipewire / pulseaudio, I can switch these using pavucontrol manually. I have

$ grep 'switch' -A 3 -B 5 ~/.config/pipewire/pipewire-pulse.conf 
pulse.cmd = [
    { cmd = "load-module" args = "module-always-sink" flags = [ ] }
    { cmd = "load-module" args = "module-device-manager" flags = [ ] }
    { cmd = "load-module" args = "module-device-restore" flags = [ ] }
    { cmd = "load-module" args = "module-stream-restore" flags = [ ] }
    { cmd = "load-module" args = "module-switch-on-connect" }
    #{ cmd = "load-module" args = "module-gsettings" flags = [ nofail ] }
]

I am unfamiliar with pipewire, and I am not sure what event I can use to trigger profile switching, and how to do it from the command line. I was under the impression that the module-switch-on-connect should do it. I can read logs and work with the command line, but I am unsure where to start debugging this.

This topic was automatically closed after 30 days. New replies are no longer allowed.