Fandom

Music Player Daemon Community Wiki

Hack:mpc-fade

525pages on
this wiki
Add New Page
Talk5 Share
  • 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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki