Skip to content

Instantly share code, notes, and snippets.

@jhuesser
Last active November 11, 2016 09:58
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 jhuesser/efa188e8ddbe43c0d616f9889768e45a to your computer and use it in GitHub Desktop.
Save jhuesser/efa188e8ddbe43c0d616f9889768e45a to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "Please use sudo configure_sound.sh."
echo "ERROR: You are not root."
exit 1
fi
apt-get update
apt-get -y install omxplayer
chmod a+rw /dev/vchiq
read -p "Please select default output: [A]udio jack | [h]dmi" output
if [[ -z "$output" ]] || [[ $output == "A" ]] || [[ $output == "a" ]]; then
amixer cset numid=3 1
elif [[ -z "$output" ]] || [[ $output == "h" ]] || [[ $output == "H" ]]; then
amixer cset numid=3 2
else
echo "invalid answer. setting to automatic."
amixer cset numid=3 0
fi
chmod a+rw /dev/vchiq
read -p "Enter path to a file to test. Leave emtpy for example file: " file2play
if [ -z "$file2play" ];
then
wget https://goo.gl/XJuOUW -O example.mp3 --no-check-certificate
omxplayer example.mp3
else
omxplayer $file2play
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment