1

I need to allow several clients to affect the volume of a central server.

Can I change the audio master volume via command line in Ubuntu 12.04?

Mild Fuzz
  • 159

3 Answers3

4
pactl -h

I just tried parameters like

pactl set-sink-volume 0 12000

To mute

pactl set-sink-mute 0 1
kenn
  • 5,162
3

Amixer is a great tool..

amixer set Master playback 5+

or

amixer set Master playback 5-
Nick K
  • 143
  • 1
  • 7
2

Type alsamixer:

This can be used to adjust both input and output volume levels.


Edit: As you seem to be displeased at my simple solution, I will add this:

Create a file in the home directory called volume:

gedit ~/volume

Then add these lines to it:

#!/bin/sh
if [ "$1" = "down" ]; then
    amixer set Master playback 5-;
    echo "";
    echo "Turned volume down a bit";
elif [ "$1" = "mute" ]; then
    amixer set Master playback 0%;
    echo "";
    echo "Muted";
else
    amixer set Master playback 5+;
    echo "";
    echo "Turned volume up a bit";
fi
exit

Save and exit, then run this to make it executable:

chmod +x ~/volume

You should then be able to control it with:

  • ~/volume, ~/volume up, ~/volume anything you like - turn the volume up
  • ~/volume down - turn the volume down
  • ~/volume mute - mute

This will needed to be to added to the home directory of each user, unless...

sudo mv ~/volume /usr/bin/volume

This will add the script file to the /usr/bin directory, which means it can be executed with just this, by every user on the system:

volume

and the command line options will still work, for example:

volume down

Note: For those thinking you can create and alias with is, it seems you can't as it does not tolerate command line options, so will only urn the volume up (in this script anyway)

Wilf
  • 30,194
  • 17
  • 108
  • 164