I cooked this up in another thread, but thought it might be generally useful, at least as a point of departure.
MC_Notifier is a bash script that submits a libnotify notification on track change in MC (which show as a floating window on many linux desktop environments). It will show the Artist, Album, and Track title. By default it runs every two seconds, but you can change that easily by modifying the "sleep" parameter (if you want it to be more responsive or eat fewer cycles). With a little more work, it might even be able to show album art, but that's a bit more work than I have time for at the moment. It will run until you kill it, so is suitable to launch with your DE's startup.
The script is kind of trivial, and it's not perfect; it performs a single very basic data validation step. So far it seems to cope with some of the usual suspects (ampersands, single quotes, double quotes, and dollar signs) just fine but it may act strangely when encountering strange characters in album titles, etc. Folks could easily make it more efficient, robust, and/or add more functionality, and I may add a few things myself over time (I have a few optimization ideas that I'll fold in myself time permitting). This is intended as a proof of concept, and is provided as is with no warranty whatsoever.
The script assumes the MC instance you want to monitor is running locally and that the server is available on the default port; you need to enable media network for it to work (I'm pretty sure the web interface depends on it). I tested on Gnome and Cinnamon, and it ran nicely. If you're running XFCE or LXDE or any of the other DE's without integrated libnotify support, you'll need a plugin/additional package to show the notifications. See here for more info:
https://wiki.archlinux.org/index.php/Desktop_notifications. The only dependency, other than basic UNIX utilities like sed, wget, and diff (which are likely to be found on any modern Linux installation) is libnotify.
#!/bin/bash
mkdir -p ~/.MC_Notifier
touch ~/.MC_Notifier/Filekey.Current
while true; do
wget -q localhost\:52199/MCWS/v1/Playback/Info\?Zone\=\-1 -O ~/.MC_Notifier/Info
mv ~/.MC_Notifier/Filekey.Current ~/.MC_Notifier/Filekey.Old
sed -n 's:.*<Item Name="FileKey">\(.*\)</Item>.*:\1:p' ~/.MC_Notifier/Info > ~/.MC_Notifier/Filekey.Current
diff ~/.MC_Notifier/Filekey.Current ~/.MC_Notifier/Filekey.Old > /dev/null
if [[ $? -ne 0 ]]; then
sed -- 's/\&/\&/g' ~/.MC_Notifier/Info > ~/.MC_Notifier/Info2
mv ~/.MC_Notifier/Info2 ~/.MC_Notifier/Info
ALBUM=$(sed -n 's:.*<Item Name="Album">\(.*\)</Item>.*:\1:p' ~/.MC_Notifier/Info)
ARTIST=$(sed -n 's:.*<Item Name="Artist">\(.*\)</Item>.*:\1:p' ~/.MC_Notifier/Info)
TRACK=$(sed -n 's:.*<Item Name="Name">\(.*\)</Item>.*:\1:p' ~/.MC_Notifier/Info)
notify-send -i "/usr/lib/jriver/Media Center 21/Data/Default Art/Logo.png" -t 2000 "$ALBUM" "$ARTIST - $TRACK"
fi
sleep 2
done
Update 08/09/2015 - The code has been updated to now show Mediacenter's Icon; I took a stab at getting it to display cover art instead , but the notification system in Gnome seems to do some kind of aggressive caching so that it won't recheck an icon file once it's loaded once (so it would only ever show the album art from the first loaded album). I'll keep tinkering with that and see if I can work it out, but for now the Mediacenter icon is better than nothing or a stock icon. If you're using MC 20, you'll need to change the "21" in the notify-send line to "20"