3

I've recently swapped to Ubuntu and am trying to emulate what I used to do with virtual audio cable on Windows. I found a great tutorial that does exactly what I want it to do, but it of course becomes a little tiresome to type in all these verbose commands every time I have to restart the machine. My commands are as follows:

pactl load-module module-null-sink sink_name=GAME sink_properties=device.description="GAME"
pactl load-module module-null-sink sink_name=MUSIC sink_properties=device.description="MUSIC"
pactl load-module module-combine-sink sink_name=GAME_and_out sink_properties=device.description="GAME_and_out", slaves=0,1
pactl load-module module-combine-sink sink_name=MUSIC_and_out sink_properties=device.description="MUSIC_and_out", slaves=0,2

I want to move the required commands into my .profile file, but this duplicates the procedure every time I log in, leading to the creation of many extra sinks that I don't need nor want.

Is there a way to either remove the old null sinks created with pactl load-module module-null-sink, or write an if block to wrap it in that will not fire if those sinks already exist?

3

Rater than putting these commands into our .profile it is recommended to add all modules needed into our /etc/pulse/default.pa or in a copy of this file in our home in ~/.pulse/default.pa resp. ~/.config/pulse/default.pa for a per user setting (which will override all settings defined in /etc/pulse/default.pa).

Adding these lines to this file:

load-module module-null-sink sink_name=GAME sink_properties=device.description="GAME"
load-module module-null-sink sink_name=MUSIC sink_properties=device.description="MUSIC"
load-module module-combine-sink sink_name=GAME_and_out sink_properties=device.description="GAME_and_out", slaves=0,1
load-module module-combine-sink sink_name=MUSIC_and_out sink_properties=device.description="MUSIC_and_out", slaves=0,2

will always load the desired NULL sinks on starting the pulseaudio sound server.

Removing sinks that had been loaded by pactl or pacmd, i.e. without settings in our default.pa can most quickly done by

pulseaudio -k

This command will kill the running pulseaudio instance, to instantaneaously respawn it (in a default set up) using values defined in the default.pa.

| improve this answer | |
  • 1
    That's beyond a perfect solution. It corrected a misconception, gave a solution, and gave me the answer to the final XY problem I asked as an addition. Thank you so much! – Adam Smith Jul 19 '15 at 21:07
  • I found it necessary (Ubuntu 18, pulseaudio 11.1) to quote sink properties as sink_properties="device.description='GAME'" – phs Jun 2 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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