Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know how to switch the audio out device using the speaker menu item, but how does one do this from the command line? I'd like to write some shell scripts around this functionality.

share|improve this question
    
see also: askubuntu.com/questions/14077/… –  Takkat Sep 17 '11 at 14:28

2 Answers 2

up vote 3 down vote accepted

This works as a script for me in Ubuntu 11.10:

pacmd "set-default-sink alsa_output.usb-Plantronics_Wireless_Audio_Plantronics_Wireless_Audio-00-Audio.analog-stereo"

pacmd "set-default-source alsa_input.usb-Plantronics_Wireless_Audio_Plantronics_Wireless_Audio-00-Audio.analog-mono"

It sets both the output and input to my wireless headset (assuming that I've plugged in the usb dongle for the headset).

The way I learned the name of the output device (sink) and input device (source) was to use these 2 commands:

pacmd "list-sinks"

pacmd "list-sources"

When you do this, you'll get a ton of info on each sink or source. You want the name, and don't copy the < or > at the beginning and end of the name.

I would really like this script to run automatically whenever I plug in the headset usb dongle. Does anyone know how to do that?

It's kind-of like when you insert media and Ubuntu asks what you want to do with it, but this isn't media: the usb headset dongle is essentially a sound card for the purposes of this script.

How can I assign what happens when a usb sound card is inserted?

share|improve this answer

Have a look at the wiki page for command line Pulseaudio and these 2 commands:

pacmd - Reconfigure a PulseAudio sound server during runtime.

pactl - Control a running PulseAudio sound server.

Some (old) examples I found on the web...

Change to jack out:

pacmd "set-default-sink jack_out" 

Enable headset:

pactl load-module module-alsa-sink device=Headset; sleep 2
pactl load-module module-alsa-source device=Headset; sleep 2
pacmd "set-default-sink alsa_output.Headset"
pacmd "set-default-source alsa_input.Headset"

Both untested: no usb headset and no jack out to test

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.