user749816 user749816 - 1 month ago 8
Linux Question

How to select the output device of audio in ubuntu manually?

In Ubuntu, we can select the output device of audio in sound preferences. But now I want to write a shell script, so I need to select the output device from the commandline.

Answer

You can first view your current default audio device by typing:

pactl stat 

And with

pactl list

you can view all your devices.

And with this command

echo "set-default-sink alsa_output.Headset" | pacmd

you can set the default device.

But I found a much better source for this problem and a included little shell script for this problem here http://ubuntuforums.org/archive/index.php/t-1370383.html