Changing the default sound output device in Counterstrike: Global Offensive (on Linux)

I know I’m about 10 years late to the party, but I recently picked up “Counter Strike: global offensive (“csgo” for short) on Linux when I found out the title was now free to play on steam.

My distro of choice is Linux Mint 19.2 and getting the game to run itself on Linux was not a big issue thanks to using modern drivers for my nvidia gtx1070ti, however no matter what I tried, csgo would insist on playing its ingame sound (both effects & VOIP) on my external speakers (when everybody knows you need a proper headset to fully enjoy the 3d effects the game provides).

After a lot of googling I finally found a workaround which involves some pulseaudio (PA) hacking, but seems to work ok in a reliable and repeatable manner.

The basic principle is that you redirect csgo’s sound output (a “sink” in PA lingo), after it’s been created,to the sound device of your choice.

You’ll need to alt-tab out of the game once it’s started but I’ve found the function is rather stable if you run csgo in “fullscreen windowed” mode.

Once csgo is running, alt-tab to a 2nd virtual desktop and open a shell.

In this new shell, we’ll need to determine the current index / id of the headset like so:

$ pactl list short sinks
0 wave_output modules/module-waveout.c s16le 2ch 44100Hz RUNNING

(the above is just an example as I’m typing this on a Linux VM). The number we need is the “0” in this case, choose this according to the index number where your headset is displayed in pactl’s output.

Next, we create a simple shell script (need to to this only once of course) with the following content, calling it “movesinks.sh” or similar:

#!/bin/bash 
echo "Setting default sink to: $1";
pacmd set-default-sink $1
pacmd list-sink-inputs | grep index | while read line
do
echo "Moving input: ";
echo $line | cut -f2 -d' ';
echo "to sink: $1";
pacmd move-sink-input `echo $line | cut -f2 -d' '` $1

done

(Source: https://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback)

I’ve chosen $HOME/bin/movesinks.sh as my location for this script, but you can put that wherever you want as long as the directory is in your PATH.

Once you have that script at the ready and executable (chmod 755 ~/bin/movesinks.sh in my case), simply type

movesinks.sh <indexnumber>

where the <indexnumber> is the number that is displayed for your headset in the pactl output listed above.

Now you can cycle back to the virtual desktop that csgo is running on, hit alt-tab there and hey presto!, csgo should now be outputting its sounds to your headset.

Thanks to “Zanna” over at askubuntu.com for the original script!

Leave a Reply

Your email address will not be published. Required fields are marked *