Set device for program in PulseAudio?

7,241

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
Share:
7,241

Related videos on Youtube

Admin
Author by

Admin

Updated on September 17, 2022

Comments

  • Admin
    Admin almost 2 years

    In computer I have 2 sound devices.

    When I run some program (let's say Skype) I can (using "pavucontrol" -> "PulseAudio Volume Control") setup so that this application will use given device for playback or recording.

    But - in the Playback/Recording tabs application is visible only if it is currently doing something (playback or recording).

    How can I set device per application, but before the application starts recording or playing sounds?

  • Vix
    Vix over 4 years
    Lovely little set of commands to find internal names, ta!!