#!/bin/bash
#
# Script to handle the multimedia buttons
# and switch interfaces between local speakers, headphones, and music server
#
if [ $# -eq 0 ]
then
exit 1
fi
sound=`cat ~/.sound.val`
if [ $1 = -vol ]
then
if [ $2 = up ]
then
val="1+"
elif [ $2 = down ]
then
val="1-"
elif [ $2 = mute ]
then
val="toggle"
else
exit 1
fi
if [ $sound = 1 ]
then
amixer set Master $val
elif [ $sound = 2 ]
then
amixer set Headphone $val
elif [ $sound = 3 ]
then
exit 1 # Place holder for the music server
fi
fi
if [ $1 = -play ]
then
if [ $sound = 3 ]
then
exit 1
else
amarok --play-pause
fi
fi
if [ $1 = -prev ]
then
if [ $sound = 3 ]
then
exit 1
else
amarok --previous
fi
fi
if [ $1 = -next ]
then
if [ $sound = 3 ]
then
exit 1
else
amarok --next
fi
fi
if [ $1 = -stop ]
then
if [ $sound = 3 ]
then
exit 1
else
amarok --stop
fi
fi
if [ $1 = -sel ]
then
if [ $2 = speakers ]
then
echo 1 > ~/.sound.val
echo Interface changed to speakers
elif [ $2 = headphones ]
then
echo 2 > ~/.sound.val
echo Interface changed to headphones
elif [ $2 = music_server ]
then
echo 3 > ~/.sound.val
echo Interface changed to music server
else
exit 1
fi
fi