Technology
 

Hack:mpd-osd.sh

From Music Player Daemon Community Wiki

[edit] Code

#!/bin/sh
# Display an OSD of the current track
COLOR="#495D94"
osd ()
{
  title=`mpc | head -1 | sed 's/^volume: [0-9]*%.*/(nothing)/'`
  position=`mpc | head -2 | tail -1 | sed 's/.*\(([0-9]*%)\)/\1/'`
   "$title" == "(nothing)"  && exit || echo "Playing:\n$title $position "
}
pid=`ps ax | grep osd_cat | sed '/grep/d' | awk '{print $1}'`
[ "$pid" ] && kill $pid
echo -e "`osd`" | \
 osd_cat -f '-bitstream-charter-bold-r-*-*-*-250-*-*-*-*-*-*' \
 -p bottom -o 15 -l 3 -A right -c "$COLOR" -s 1 -d 4

[edit] Auto-repeating variant

This script shows OSD every time song is changed (may appear several odd times)

#!/bin/sh
# Display an OSD of the current track
COLOR="#495D94"
osd ()
{
  title=`mpc | head -1 | sed 's/^volume: [0-9]*%.*/(nothing)/'`
  position=`mpc | head -2 | tail -1 | sed 's/.*\(([0-9]*%)\)/\1/'`
   "$title" == "(nothing)"  && exit || echo "Playing:\n$title $position "
}
while true; do
   pid=`ps ax | grep osd_cat | sed '/grep/d' | awk '{print $1}'`
   [ "$pid" ] && kill $pid
   echo "`osd`" | \
     osd_cat -f '-bitstream-charter-bold-r-*-*-*-250-*-*-*-*-*-*' \
     -p bottom -o 15 -l 3 -A right -c "$COLOR" -s 1 -d 4
   echo "idle" | netcat localhost 6600 | wait
done

[edit] UTF-8

If you are expiriencing problems displaying utf-8 tags try using fonts that have iso10646 encoding. For example "-rfx-helvetica-bold-r-*-*-*-250-*-*-*-*-iso10646-*". You can find other fonst using this command:

xlsfonts |grep iso10646