Automatically Change Volume After PulseAudio Starts


I am suffering from the problem described here and here, which unfortunately still hasn't been fixed. Basically after rebooting my computer my volume is at 100% until I trigger the volume. What I mean by this is that the software volume indicator is showing the setting that was set before (e.g. 20%) however the actual sound will be played at 100% until I move the slider a bit and the system "realises" what the volume setting is. I am using an external DAC (which is like a USB soundcard) which is a Schiit Audio.

As a workaround I'm trying to trigger the volume by adding the following command to the startup applications list (Session and Startup) as suggested here:

pacmd set-sink-volume 2 20000

Unfortunately this doesn't seem to work, possibly because the Pulse Audio System is not running yet when the command is executed. I've tried sleeping before executing it, but that doesn't help either; moreover I want to have a guarantee that the volume has been set properly so that I don't have to live a stressful life 😉

I've tried renaming my task so that it is at the end of the list to no avail.

Is there any other way for me to set the volume automatically after Pulse Audio loads? I don't want to get a heart attack every time I forget to retrigger the volume after login…

I am using Xubuntu 14.04.

Best Answer

The pulseaudio module responsible to restore any device's volume to values before rebooting is the module-device-restore. If restoring devices does not work as expected we may want to check if that module was loaded with:

pacmd list-modules

If it was not there we should add the module to our settings file. This file is located in /etc/pulse by default but we can have an additinal per-user overriding this in ~/.pulse/ or in ~/.config/pulse/. When editing make sure you choose the appropriate file, and make a backup beforehand.

To load module-device-restore on starting the pulseaudio sound server the following line has to be included (or uncommented) in the

load-module module-device-restore