Notify about tracks played by mpd
This runs in background and produces notifications whenever mpd produces an event, that is new track is played or playback is paused or stopped. Notifications look like this:
This now even supports album artwork:
Read below for the details.
To compile and run
mpd-notification you need:
- file for
- libav or ffmpeg
- markdown (HTML documentation)
adwaita-icon-theme(or anything else that includes an icon named
mpd-notification you probably want
music player daemon itself. ;)
Some systems may require additional development packages for the libraries.
libmpdclient-devel or similar.
Building and installing is very easy. Just run:
This will place an executable at
documentation can be found in
Additionally a systemd unit file is installed to
mpd-notification to run it once. A systemd user service can be
started and/or enabled with
systemctl --user start mpd-notification
systemctl --user enable mpd-notification.
mpd-notification accepts some arguments:
- -h: show help
- -H HOST: connect to HOST
- -m MUSIC-DIR: use MUSIC-DIR for artwork lookup
- --notification-file-workaround: write artwork to file for notification daemons that do required it
- -o: Notification text is one line (no line breaks)
- -p PORT: connect to PORT
- -s PIXELS: scale image to a maximum size PIXELS x PIXELS pixels, keeping ratio
- -t TIMEOUT: notification timeout, TIMEOUT in seconds
- -v: verbose output
- -V: print version information
Configuration options can be read from a configuration file.
tries to read
~/.config/mpd-notification.conf, which is expected to
look like this:
host = localhost port = 6600 music-dir = /srv/media/music/ oneline = true scale = 200 timeout = 20
Unused options can be commented or removed completely.
mpd does not provide any information where it finds its music files. To make
mpd-notification display album artwork you need to tell it where to look for
artwork. You can do that by exporting
XDG_MUSIC_DIR to your environment, by
--music-dir on the command line or by setting
in configuration file.
mpd-notification reads album artwork from
files, otherwise an image file containing the artwork needs to be placed
in the same directory as the media file and named