8

When I reboot, the volume on the PulseAudio sinks is set to 100%. I know how to change the volume using pactl set-sink-volume, but that is only set temporarily. I could write a script that is run at startup, but it will not be applied if I connect a sink later. (i.e. a Bluetooth speaker)

Is there a config file where I can set the default volume that is given to a device when it is first loaded by PulseAudio? Or even the master volume at startup?

Clarification: The application is for a headless linux box, so the system shouldn't have to be rebooted and should be able to accept new devices without having to connect via ssh to adjust volumes, etc.

4 Answers 4

4

What worked for me was to go into ~/.config/pulse/default.pa and scroll to the bottom to set-sink-volume and change the value to 0

3

Set the volume to your desired level and then type in a terminal:

sudo alsactl store

Now, it should be stored even after reboot.

1
  • Thank you for the response. This is to save the settings for an already configured driver, which I guess is half the battle. However, what about a card that has never been seen before? I would prefer if ALSA or PulseAudio would add this new card, automatically, with a lower volume.
    – MrUser
    Jun 4, 2014 at 9:26
3

With PulseAudio 8.0 on Ubuntu 16.04 and a single sound card, you can set the default master volume to 50% with the following file. By including the system default you don't have to worry about changes in the distribution's defaults.

$ cat ~/.config/pulse/default.pa
.include /etc/pulse/default.pa

# Set volume to 50% on boot
set-sink-volume 0 32768

If you have multiple cards, replace the index number with the name since order is not guaranteed. In addition, if you want to adjust the volume determine the "base volume" which represents the max and calculate the equivalent percentage.

$ pacmd list-sinks | grep -e "name:" -e "index:" -e "base volume:"
  * index: 0
    name: <alsa_output.card0>
    base volume: 65536 / 100% / 0.00 dB
  * index: 1
    name: <alsa_output.card1>
    base volume: 32768 / 100% / 0.00 dB

For example, to specify the default volume of 70% for card1 the line would become:

set-sink-volume alsa_output.card1 22937
0

You can create separate script and run it from the startup so every time you reboot the system it check the particular sink volume.

Here is the script:

 export sink_index=$(pactl list short sinks | awk -v index_number=<sink_name> '$2==index_number {print $1}')
            volume=$(pactl list sinks | perl -000ne 'if(/#$ENV{sink_index}/){/(Volume:.*)/; print "$1\n"}' | sed 's/.*\ \(.*\)%.*/\1/g')
            if [ $volume -ne 100 ]; then
                pactl set-sink-volume $sink_index 100%
            fi

The sink_name should be your bluetooth sink or sink that you want to set volume.

You can find the bluetooth sink from:

pactl list short sinks | grep "alsa_output" | awk '{ print $2 }' | head -n1

Hope these will help you.

2
  • Thanks, but if the computer is already on and I connect a new device, then I have to go into the terminal and use pactl to set the volume still. A startup script won't work, because the bluetooth device won't be connected at startup. Pulseaudio only loads the device's sound card once it's connected.
    – MrUser
    Jun 4, 2014 at 9:31
  • @MrUser -Instead of run this script from startup, you can run this script in background and check the bluetooth sink volume if it is not 100% then you can set to 100% Jun 4, 2014 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .