mpd / mpc: fade in / out script


For the ones like me who want to wake up with music and go to sleep with music, here is a little script to make the magic around mpd.
It will work on any linux with mpd and mpc (mpd client).
On the mele, you have a led extra when mpc-fade is running.

Here it is: mpc-fade
‘chmod a+x’ the file.

It keeps the volume and the playlist from the previous mpd run.

In fade-in (wake-up), it will raise the volume until it reaches the previous mpd volume and keep playing.

In fade-out (sleep), it will down the volume until it reached the given limit, stop mpd and restore the previous volume.

During the fade, mpd repeat mode is activated.


Usage: mpc-fade [OPTION]  
   -d       : daemonize - for crontab or lirc irexec

   diff-vol : volume from start to end
              * negative: fade-out (and stop)
              * positive: fade-in (and continue to play)
   duration : fade-in/out duration


You can edit mpc-fade and change the BACKUP_ALBUM.
In case your mpd have no active playlist, it will load this album.


A fade-in (wake-up during 15 min.)

./mpc-fade 50 900

A fade-out (sleep in 30 min.)

./mpc-fade -50 1800

In crontab:

Create a “/etc/cron.d/wakeup-cron”.
Wake-up at 7:30 from Monday to Friday in 2 minutes.
Wake-up at 9:30 from Saturday to Sunday in 4 minutes.

30 7 * * 1,2,3,4,5	root	/mpc-fade -d 60 120
30 9 * * 6,7		root	/mpc-fade -d 60 240

Mechanize in lirc with irexec

Sleep in 20 minutes on POWER button press.
In your lircd configured, add in your .lircrc something like that:

     prog = irexec
     button = POWER
     config = /mpc-fade -d -60 1200
     repeat = 0

1 thought on “mpd / mpc: fade in / out script

  • Offtopic: I tried to add mp3 songs to mpd and mpd segfaults. After debuging I found out that mp3 lib breaks on importing soungs. Mpd and lossless content – works. XBMC crahses too on tryint to play mp3. Do you know about this bug?

Leave a Reply

Your email address will not be published. Required fields are marked *