Sound configuration is lost on restart

I have an Acer TravelMate P648-MG laptop. I had troubles getting sound to work until I found pavucontrol. There, in the Configuration tab, I can set the configuration to Analog Stereo Duplex. Then I have a single output device called "Built-in Audio Analog Stereo" with three ports: Speakers (that is the laptop's internal speakers), Line out and "Headphones (unplugged)" (yes, the "unplugged" part is there). When I set the port to "Headphones (unplugged)" then the sound goes where it should - to the plugged speakers/headphones.

However, every time I restart (or just restart pulseaudio with pulseaudio -k) this setting is lost. I usually end up with Speakers set as the port for the output device. How can I store this setting permanently?

It's Ubuntu Gnome 16.10. Feel free to ask for additional data (logs, hardware configuration, etc.).


Solution 1:

Pulseaudio can not automatically connect to a headset that may or may not be present on startup. It will always try to connect to the next available device, which usually would be "internal analog".

To ovecome this we may load a pulseaudio module that allows autoconnecting to an additional sound device as soon as it was connected with:

pactl load-module module-switch-on-connect

If it does what is expected we can load it everytime pulseaudio starts by adding the following line to our /etc/pulse/default.pa (or ~/.config/pulse/default.pa if we had defined it locally):

load-module module-switch-on-connect

After an edit of default.pa pulseaudio needs to be restarted with pulseaudio -k for changes to take effect.


Above module only works on plugging in the headphones. In case it was always plugged in we may add the following line to the end of the default.pa:

set-sink-port <name|index>  analog-output-headphones

The name or index of the active sink, and available ports can be displayed with pactl list sinks.