MPD OSD
Mike Massonnet | Posted 3 weeks, 2 days ago on April 26, 2006
I wrote me a script to display an OSD of the current played track by MPD. Next I also wrote a script to display an OSD (using the first script) when the track changes.
Each script uses mpc. I set a key binding on a useless multimedia touch to the first script. The second script should be run in background.
mpd-osd.sh
#!/bin/sh
# Display an OSD of the current track
track ()
{
title=`mpc | head -1 | sed 's/^volume: [0-9]*%.*/(nothing)/'`
position=`mpc | head -2 | tail -1 | sed 's/.*\(([0-9]*%)\)/\1/'`
[[ "$title" == "(nothing)" ]] && echo "$title" || echo "$title $position"
}
pid=`ps ax | grep osd_cat | sed '/grep/d' | awk '{print $1}'`
[ "$pid" ] && kill $pid
echo -e "Playing:\n"`track`" " | \
osd_cat -f '-bitstream-bitstream charter-bold-r-*-*-*-250-*-*-*-*-*-*' \
-p bottom -o 10 -l 3 -A right -c '#89B83F' -s 2 -d 4
mpd-new-track.sh
#!/bin/sh
# Display an OSD when the track is changed
function setNewOSD ()
{
tmp=/tmp/mpd-new-track.sh
currentTrack=`mpc | head -1`
lastTrack=`cat $tmp`
echo "$currentTrack" > $tmp
[ "$currentTrack" != "$lastTrack" ] && mpd-osd.sh&
}
while sleep 1
do
setNewOSD
done