Last active
July 5, 2018 14:51
-
-
Save grepwood/9e0e8b987839919d78255c933a1e6964 to your computer and use it in GitHub Desktop.
Workaround for audio bugs in Gentoo to make Civ5 work again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
function disable_pa { | |
if [ $(sudo grep ^autospawn /etc/pulse/client.conf | wc -l) -ne 0 ]; then | |
sudo sed 's/^autospawn\ =\ yes/autospawn\ =\ no/g' -i /etc/pulse/client.conf | |
else | |
sudo su - -c "echo 'autospawn = no' >> /etc/pulse/client.conf" | |
fi | |
echo "Disabled Pulseaudio" | |
} | |
function kill_pa { | |
kill -15 $(ps aux | grep pulseaudio | grep -v grep | awk '{print $2}') | |
echo "Killed Pulseaudio with SIGTERM" | |
} | |
function start_civ5 { | |
# Change the timeout depending on your computer's speed of starting up Civ5 | |
# On mine 10 is more than enough. | |
local timeout=10 | |
steam steam://rungameid/8930 | |
printf "Started Civ5. Waiting until X window appears... " | |
# Ideally we should wait until Civ5 fails to initialize audio backends and goes on | |
# while [ $(xwininfo -tree -root | grep '"Sid Meier'"'s"' Civilization V": ("Civ5XP" "Civ5XP")' | wc -l) -ne 0 ]; do | |
# sleep 1 | |
# done | |
sleep ${timeout} | |
echo "done" | |
} | |
function enable_pa { | |
sudo sed 's/autospawn\ =\ no/autospawn\ =\ yes/g' -i /etc/pulse/client.conf | |
echo "Enabling Pulseaudio" | |
} | |
function main { | |
disable_pa | |
kill_pa | |
start_civ5 | |
enable_pa | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment