{"id":2061,"date":"2020-04-09T14:00:55","date_gmt":"2020-04-09T13:00:55","guid":{"rendered":"https:\/\/hoover.gplrank.de\/?p=2061"},"modified":"2020-04-09T14:03:58","modified_gmt":"2020-04-09T13:03:58","slug":"changing-the-default-sound-output-device-in-counterstrike-global-offensive-on-linux","status":"publish","type":"post","link":"https:\/\/hoover.gplrank.de\/?p=2061","title":{"rendered":"Changing the default sound output device in Counterstrike: Global Offensive (on Linux)"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/730\/header.jpg?t=1585696022\" alt=\"\"\/><\/figure>\n\n\n\n<p>I know I&#8217;m about 10 years late to the party, but I recently picked up &#8220;Counter Strike: global offensive (&#8220;csgo&#8221; for short) on Linux when I found out the title was now free to play on steam.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>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 &amp; VOIP) on my external speakers (when everybody knows you need a proper headset to fully enjoy the 3d effects the game provides).<\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>The basic principle is that you redirect csgo&#8217;s sound output (a &#8220;sink&#8221; in PA lingo), after it&#8217;s been created,to the sound device of your choice. <\/p>\n\n\n\n<p>You&#8217;ll need to alt-tab out of the game once it&#8217;s started but I&#8217;ve found the function is rather stable if you run csgo in &#8220;fullscreen windowed&#8221; mode.<\/p>\n\n\n\n<p>Once csgo is running, alt-tab to a 2nd virtual desktop and open a shell. <\/p>\n\n\n\n<p>In this new shell, we&#8217;ll need to determine the current index \/ id of the headset like so: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ pactl list short sinks<br>0 wave_output modules\/module-waveout.c s16le 2ch 44100Hz RUNNING<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>(the above is just an example as I&#8217;m typing this on a Linux VM). The number we need is the &#8220;0&#8221; in this case, choose this according to the index number where your headset is displayed in pactl&#8217;s output. <\/p>\n\n\n\n<p>Next, we create a simple shell script (need to to this only once of course) with the following content, calling it &#8220;movesinks.sh&#8221; or similar: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash \necho \"Setting default sink to: $1\";\npacmd set-default-sink $1\npacmd list-sink-inputs | grep index | while read line\ndo\necho \"Moving input: \";\necho $line | cut -f2 -d' ';\necho \"to sink: $1\";\npacmd move-sink-input `echo $line | cut -f2 -d' '` $1\n\ndone<\/code><\/pre>\n\n\n\n<p>(Source: <a href=\"https:\/\/askubuntu.com\/questions\/71863\/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback\">https:\/\/askubuntu.com\/questions\/71863\/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback<\/a>)<\/p>\n\n\n\n<p>I&#8217;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. <\/p>\n\n\n\n<p>Once you have that script at the ready and executable (chmod 755 ~\/bin\/movesinks.sh in my case), simply type <\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">movesinks.sh &lt;indexnumber&gt;<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>where the &lt;indexnumber&gt; is the number that is displayed for your headset in the pactl output listed above. <\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Thanks to &#8220;<a href=\"https:\/\/askubuntu.com\/users\/527764\/zanna\">Zanna<\/a>&#8221; over at askubuntu.com for the original script! <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I know I&#8217;m about 10 years late to the party, but I recently picked up &#8220;Counter Strike: global offensive (&#8220;csgo&#8221; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2061","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2061"}],"version-history":[{"count":2,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2061\/revisions"}],"predecessor-version":[{"id":2063,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2061\/revisions\/2063"}],"wp:attachment":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}