Set device for program in PulseAudio?

Solution 1:

I don't know if there is a setting or configuration file for this anywhere but it can be done with environment variables. I've based my answer on this entry in the PulseAudio FAQ about setting the recording source. I've tried this with output (a sink in PulseAudio) but it should work for both input and ouput.

The first step is to get the internal name of the source and sink that you want to use. To do that you need to use the pactl list command. That command will return a pile of data, but the following will list just the source names:

LANG=C pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2

That list will probably include the names for both regular sources and PulseAudio's monitor sources (which on my system have "monitor" in the name). You'll want to use the regular source name of the device you want to target.

You can do the same thing to get the sink names:

LANG=C pactl list | grep -A2 'Sink #' | grep 'Name: ' | cut -d" " -f2

Once you've got the names you can run something like the following from your terminal:

PULSE_SINK=<sink_name> PULSE_SOURCE=<source_name> <command_to_run_skype>

Of course, if you want to run this from a menu you'll probably need to create a shell script and use that instead of the default command. Something like this should work:

#!/bin/sh
set PULSE_SINK <sink_name>
set PULSE_SOURCE <source_name>
<command_to_run_skype>

Solution 2:

You need to EXPORT and assign the variables, like this:

#!/bin/sh 
export PULSE_SINK="sink_name" 
export PULSE_SOURCE="source_name" 
command_to_run_skype