Hooks are executed depending on the event received from mpd. Hooks are stored under MPDCRON_DIR/hooks where MPDCRON_DIR is ~/.mpdcron by default. Here’s a list of hooks and commands run before them:

Hook Command
hooks/database stats
hooks/stored_playlist -
hooks/playlist -
hooks/player status & currentsong
hooks/mixer status
hooks/output -
hooks/options status
hooks/update status

Note: As of version 0.4, mpdcron doesn’t send any commands to the server before events stored_playlist, playlist and outputs because the number of environment variables may result in huge numbers causing mpdcron to hang. See #3 for more details.

Environment variables

Here’s a list of environment variables mpdcron sets depending on the command sent:

currentsong

Environment variable Explanation
MPD_SONG_URI URI of the song
MPD_SONG_LAST_MODIFIED Time of last modification
(format: "%Y-%m-%d %H-%M-%S %Z")
MPD_SONG_DURATION Duration of the song in seconds
MPD_SONG_DURATION Duration of the song in seconds
MPD_SONG_POS Position of the song in the queue
MPD_SONG_ID Song ID
MPD_SONG_TAG_ARTIST Artist tag
MPD_SONG_TAG_ALBUM Album tag
MPD_SONG_TAG_ALBUM_ARTIST Album artist tag
MPD_SONG_TAG_TITLE Title tag
MPD_SONG_TAG_TRACK Track tag
MPD_SONG_TAG_NAME Name tag
MPD_SONG_TAG_GENRE Genre tag
MPD_SONG_TAG_DATE Date tag
MPD_SONG_TAG_COMPOSER Composer tag
MPD_SONG_TAG_COMMENT Comment tag
MPD_SONG_TAG_DISC Disc tag
MPD_SONG_TAG_MUSICBRAINZ_ARTISTID Musicbrainz artist ID
MPD_SONG_TAG_MUSICBRAINZ_ALBUMID Musicbrainz album ID
MPD_SONG_TAG_MUSICBRAINZ_ALBUMARTISTID Musicbrainz album artist ID
MPD_SONG_TAG_MUSICBRAINZ_TRACKID Musicbrainz track ID

stats

Environment variable Explanation
MPD_DATABASE_UPDATE_TIME Date specifying last update time
(format: "%Y-%m-%d %H-%M-%S %Z")
MPD_DATABASE_ARTISTS Number of artists
MPD_DATABASE_ALBUMS Number of albums
MPD_DATABASE_SONGS Number of songs
MPD_DATABASE_PLAY_TIME Accumulated time mpd was playing music since the process was started
MPD_DATABASE_UPTIME Uptime of mpd in seconds
MPD_DATABASE_DB_PLAY_TIME Accumulated duration of all songs

status

Environment variable Explanation
MPD_STATUS_VOLUME Volume
MPD_STATUS_REPEAT Repeat
(boolean, 0 or 1)
MPD_STATUS_RANDOM Random
(boolean, 0 or 1)
MPD_STATUS_SINGLE Single
(boolean, 0 or 1)
MPD_STATUS_CONSUME Consume
(boolean, 0 or 1)
MPD_STATUS_QUEUE_LENGTH Queue/Playlist length
MPD_STATUS_CROSSFADE Crossfade in seconds
MPD_STATUS_SONG_POS Position of the current playing song
MPD_STATUS_SONG_ID ID of the current playing song
MPD_STATUS_ELAPSED_TIME Elapsed time in seconds
MPD_STATUS_ELAPSED_MS Elapsed time in milliseconds
MPD_STATUS_TOTAL_TIME Total time in seconds
MPD_STATUS_KBIT_RATE Current bit rate in kbps
MPD_STATUS_UPDATE_ID ID of the update
MPD_STATUS_STATE State, one of play, pause, stop or unknown
MPD_STATUS_AUDIO_FORMAT Specified whether audio format is available
(boolean, 0 or 1)
MPD_STATUS_AUDIO_FORMAT_SAMPLE_RATE Sample rate in Hz
MPD_STATUS_AUDIO_FORMAT_BITS Number of significant bits per sample
MPD_STATUS_AUDIO_FORMAT_CHANNELS Number of channels
(1 for mono, 2 for stereo)