From Music Player Daemon Community Wiki
- Description: Alarm clock fade
- Author: Maxime Petazzoni, aka Sam
- Webpage: www.bulix.org
- Licence: GNU General Public Licence
- Other info: usefull when used along with at to do the alarm clock job
- Source:
#!/bin/sh
BACKUP_SONG="~/.welcome.ogg"
BACKUP_VOLUME=100
MPC=`which mpc`
BC="`which bc` -l"
MPDRUNFILE="/var/run/mpd.pid"
backup_wakeup ()
{
mpc volume $BACKUP_VOLUME > /dev/null
ogg123 -q -d alsa09 $BACKUP_SONG
}
if [ $# -ne 3 ] ; then
echo "usage: mpc-fade <start volume> <end volume> <length in secs>" ;
exit 1 ;
fi
# check if mpd is running, and with some files to play
if [ ! -e $MPDRUNFILE ] ; then
backup_wakeup ;
fi
if [ `mpc playlist | wc -l` -eq 0 ] ; then
backup_wakeup ;
fi
VOLUME=$1
$MPC play > /dev/null
if [ $1 -lt $2 ] ; then
while [ $VOLUME -le $2 ] ; do
$MPC volume $VOLUME > /dev/null ;
VOLUME=$(($VOLUME + 1)) ;
sleep `echo "$3/($2-$1)" | $BC` ;
done ;
else
while [ $VOLUME -ge $2 ] ; do
$MPC volume $VOLUME > /dev/null ;
VOLUME=$(($VOLUME - 1)) ;
sleep `echo "$3/($1-$2)" | $BC` ;
done ;
fi
exit 0
# eof