I'm a big fan of
Conky (for the unfamiliar, it's a lightweight highly customizable system monitoring/scriptable display tool for linux). People have integrated weather apps, system upgrade notifications, rss feeds, and almost anything else you can think of into Conky, basically turning it into a replacement sytem tray/notification system for X11 desktops. Conky also has integration with several Linux music players, most notably mpd. Conky has built in support to show all kinds of metadata from mpd and a few other players, so I decided to do some work to try and get basic "homemade" conky integration with JRiver using MCWS.
You can see what my "first draft" looks like on the right side of the desktop. I'm still trying to work out a few issues with how it interacts with my normal conky (on the left hand side of the screen), but that's kind of a side issue. I've got it fetching and displaying the currently playing Artist, Album, Track Title, Duration, and the Cover Art in real time. I also managed to script some "intelligent" scrolling so that the text entries scroll only when they're longer than will fit in the available space. That said, Conky's built in scroll feature is a little "dumb" (lots of white space between scrolls), but it works in a basic way.
I'm going to post the code below with the following caveats:
1) You'll need to tweak this based on the size of your display, your window manager, and about a half dozen other things. There's really no such thing as a "drop in" conky configuration.
2) These scripts will not be winning any awards for beauty, efficiency, or code correctness. They mostly work, but do a few things that are frowned on by professionals (like using regex to parse XML strings, which I have on good authority
will result in ponies eating your face). For that reason, it's not likely to be super portable, or a good fit for low-powered devices (like a Pi).
3) I tried to avoid doing anything that seemed obviously dangerous, and built in one or two data validation features (more to come), *BUT* this code is provided as is for informational purposes without any guarantee of safety, suitability, etc. If you have an album with a fork bomb for a name, you're on your own. If you don't know what any of this does, don't run it.
The scripts all assume that they'll be in a directory named ".MCWS" in the home directory of the user who is running conky. Feel free to put them wherever you like, but remember to change the scripts
The main script (Fetcher) fetches an XML file using MCWS that has general info about what's playing, as well as fetching the album art, and performing a data validation step.
#!/bin/bash
#Fetch the xml
wget -q localhost\:52199/MCWS/v1/Playback/Info\?Zone\=\-1 -O ~/.MCWS/Info
#Lift out the image URL
URL=$(sed -n 's:.*<Item Name="ImageURL">\(.*\)</Item>.*:\1:p' ~/.MCWS/Info)
#Fetch the Image
wget localhost:52199/$URL -O ~/.MCWS/img.jpg
#Fix ampersands
sed -- 's/\&/\&/g' ~/.MCWS/Info > ~/.MCWS/Info2
mv ~/.MCWS/Info2 ~/.MCWS/Info
Then (because Conky only really handles one line at a time) we have separate scripts for each of the data elements we're pulling. For example, the Artist script looks like this:
#!/bin/bash
~/.MCWS/Fetcher
ARTIST=$(sed -n 's:.*<Item Name="Artist">\(.*\)</Item>.*:\1:p' ~/.MCWS/Info)
echo $ARTIST
The Album, Name, ElapsedTimeDisplay, and TotalTimeDisplay scripts are identical except for replacing Artist with the appropriate term in all instances.
The relevant part of the final conky configuration file (under the TEXT header in the .conkyrc) is set up like this on a 1920x1080 screen:
${goto 1250}${color} JRiver
${goto 1252}${color} Artist: ${if_match "35" <= "${exec ~/.MCWS/Artist | wc -m}"} ${alignr 265}${scroll 33 ${execi 1 ~/.MCWS/Artist}} ${else} ${alignr 265}${execi 1 ~/.MCWS/Artist}${endif}
${goto 1252}${color} Album: ${if_match "35" <= "${exec ~/.MCWS/Album | wc -m}"} ${alignr 265}${scroll 33 ${execi 1 ~/.MCWS/Album}} ${else} ${alignr 265}${execi 1 ~/.MCWS/Album}${endif}
${goto 1252}${color} Track: ${if_match "35" <= "${exec ~/.MCWS/Track | wc -m}"} ${alignr 265}${scroll 33 ${execi 1 ~/.MCWS/Track}} ${else} ${alignr 265}${execi 1 ~/.MCWS/Track}${endif}
${goto 1252}${color} Time: ${alignr 265}${execi 1 ~/.MCWS/Elapsed_Time} / ${execi 1 ~/.MCWS/Total_Time}
${image ~/.MCWS/img.jpg -p 1255,550 -s 400x400 -f 2}
I'm sure that looks like an unholy mess, but unfortunately Conky treats white space as actual white space, so every space you add affects the final spacing. One of my first improvement steps will be trying to find ways to clean this up without messing up the design. Hopefully this is helpful for someone (or at least some people who know bash and regex much better than me will offer constructive criticism
)