Created
December 18, 2016 18:16
-
-
Save n1zzo/289826bab5747d1dc73c4dcd3e171ed7 to your computer and use it in GitHub Desktop.
Switches from local and remote pulseaudio server configurations. statefully.
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
#! /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