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:
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