Skip to content

Instantly share code, notes, and snippets.

@grepwood
Last active July 5, 2018 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grepwood/9e0e8b987839919d78255c933a1e6964 to your computer and use it in GitHub Desktop.
Save grepwood/9e0e8b987839919d78255c933a1e6964 to your computer and use it in GitHub Desktop.
Workaround for audio bugs in Gentoo to make Civ5 work again
#!/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