Ubuntu's desktop gui is great for changing audio settings (System->Preferences->Sound), like the default input/output device and setting the volume.
However, I would like to be able to do these things from the command-line. What tool is the gui using behind the scenes?
Best Answer
You can control PulseAudio thoroughly through the command line using
pacmd
andpactl
commands. For options see man pages or the wiki at PulseAudio:pacmd list-sinks
(orpactl list short sinks
) for name or index number of possible sinkspacmd set-default-sink "SINKNAME"
to set the default output sinkpacmd set-default-source "SOURCENAME"
to set the default inputpacmd set-sink-volume index volume
pacmd set-source-volume index volume
for volume control (65536
= 100 %,0
= mute; or a bit more intuitive0x10000
= 100 %,0x7500
= 75 %,0x0
= 0 %)and many many more CLI options.
Note: Changing the output sink through the command line interface can only take effect if stream target device reading is disabled. This can be done by editing the corresponding line in
/etc/pulse/default.pa
to:Restart PulseAudio for changes to take effect:
pulseaudio -k
For a more elaborate tutorial on how to do this, and for instructions on how to change the sink during playback see this answer.