Skip to content


MPDCRON – A simple usefull tool

I wrote a very tiny tool yesterday; mpdcron.

mpdcron is a ‘cron’ like program for mpd.  It can execute scripts based on mpd’s idle events.

You can specify this in a very simple config file.  You first list the event it should react on, then the command it should execute. You can let one script respond to multiple events by combining them with a pile. (Like you would in C)

For example an entry like this:

OPTIONS|MIXER  /home/qball/scripts/mpd_control_mixer_changed.sh

The script mpd_control_mixer_changed.sh is called when either options changed (f.e. random, repeat etc.) or the mixer changed f.e. volume levels.

The following events are available:

DATABASE: The database changed.

STORE_PLAYLIST: One or more stored playlists are modified/created/deleted.

QUEUE: The play-queue changed.

PLAYER: The state of the player changed. f.e. stopped/paused or the song changed.

MIXER: The volume mixer changed.

OUPUT: One or more outputs got enabled/disabled.

OPTIONS: Repeat/Random or another option has changed.

UPDATE: The database started or stopped updating.

The config file can contain an arbitrary number of lines.

It takes the following command line parameters:

One or more config files. If none is specified it tries ~/.mpdcron

-f: Run in foreground

–hostname=<name>: Set hostname

–port=<port>: Set the port number

–help/-h: Print help message

It also responds to the MPD_HOST/MPD_PORT environment variable.

The program uses MPD’s idle command. So it does not poll or anything, it just waits for mpd to notify it off a change.  It  should be very lightweight and low on resources.

Dependencies: libmpdclient 2.0

It is currently available in git (http://repo.or.cz/w/mpdcron.git ), in the mpd-trunk ppa (ubuntu) or as AUR package (archlinux).

Posted in mpd.

3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. gregf said

    Pretty sweet looking just added this to the mpd-overlay.

  2. Fux said

    wow, indeed a interesting tool. Could the player change (PLAYER) be more specified, f.e. only execute the command when a song is changing?

  3. That is partially implemented in the latest version. (See the README file)

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.