Skip to content

Instantly share code, notes, and snippets.

@n1zzo
Created December 18, 2016 18:16
Show Gist options
  • Save n1zzo/289826bab5747d1dc73c4dcd3e171ed7 to your computer and use it in GitHub Desktop.
Save n1zzo/289826bab5747d1dc73c4dcd3e171ed7 to your computer and use it in GitHub Desktop.
Switches from local and remote pulseaudio server configurations. statefully.
#! /bin/sh
PULSE_USER=nico
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
function pa_remote {
echo "Enabling remote pulseaudio server"
sed -i.bak 's/; default-server/default-server/' /etc/pulse/client.conf
touch /etc/pulse/remote
}
function pa_local {
echo "Disabling remote pulseaudio server"
sed -i.bak 's/default-server/; default-server/' /etc/pulse/client.conf
rm /etc/pulse/remote
}
# Switch between local and remote configuration
[ -f /etc/pulse/remote ] && pa_local || pa_remote
# Restart pulseaudio
su $PULSE_USER
pulseaudio --kill
pulseaudio -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment