Hack:mpd-osd.sh
Talk0
542pages on
this wiki
this wiki
Contents |
Code
Edit
#!/bin/sh
# Display an OSD of the current track
COLOR="#495D94"
FONT="-bitstream-charter-bold-r-*-*-*-250-*-*-*-*-*-*"
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 "$FONT" -p bottom -o 15 -l 3 -A right -c "$COLOR" -s 1 -d 4
A alternative version
Edit
A simpler and less CPU intensive version, of same script above:
#!/bin/sh
# Display an OSD of the current track
COLOR="#495D94"
FONT="-bitstream-charter-bold-r-*-*-*-250-*-*-*-*-*-*"
track ()
{
title=`mpc -f [[[%name%]%artist%]\ %title%] current`
position=`mpc -f [%time%] | grep "pl" | awk '{print $4 }'`
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 "$FONT" -p bottom -o 40 -l 2 -A left -c "$COLOR" -s 2 -d 4
Auto-repeating variant
Edit
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"
FONT="-bitstream-charter-bold-r-*-*-*-250-*-*-*-*-*-*"
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 "$FONT" -p bottom -o 15 -l 3 -A right -c "$COLOR" -s 1 -d 4
echo "idle" | netcat localhost 6600 | wait
done
UTF-8
Edit
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