Okay, I lied.
Code:
#! /bin/sh
#
# $Id$
#
# Fugly POC
# Be nice!
renice -n 10 $$
# Do some minimal device checks...
# Use Futura if it exists
if [ -f "/usr/java/lib/fonts/Futura-DemiBold.ttf" ] ; then
CLOCK_FONT="/usr/java/lib/fonts/Futura-DemiBold.ttf"
else
# Barring that, go with Caecilia, because Helvetica is friggin awful.
CLOCK_FONT="/usr/java/lib/fonts/Caecilia_LT_75_Bold.ttf"
fi
# Detect the correct screen size... (Adapted from the logic in BatteryStatus)
kmodel="$(cut -c3-4 /proc/usid)"
case "${kmodel}" in
"24" | "1B" | "1D" | "1F" | "1C" | "20" | "D4" | "5A" | "D5" | "D6" | "D7" | "D8" | "F2" )
# PaperWhite...
SCREEN_X_RES=758
SCREEN_Y_RES=1024
;;
* )
# Handle legacy devices...
if [ -f "/etc/rc.d/functions" ] && grep "EIPS" "/etc/rc.d/functions" > /dev/null 2>&1 ; then
. /etc/rc.d/functions
else
# Touch
SCREEN_X_RES=600 # _v_width @ upstart/functions
SCREEN_Y_RES=800 # _v_height @ upstart/functions
fi
;;
esac
# NOTE: Mostly randomly chosen, tweak me if needed
case "${SCREEN_Y_RES}" in
"800" )
CLOCK_SIZE="${SCREEN_X_RES}x20"
;;
"1200" )
# FIXME: Can't remember if /etc/rc.d/functions is actually accurate on DX/DXG, or if we need to fake it ourselves
CLOCK_SIZE="${SCREEN_X_RES}x30"
;;
"758" )
CLOCK_SIZE="${SCREEN_X_RES}x26"
;;
esac
# And the actual work...
clock_watch()
{
LAST_TIME="13:37"
# Let's loop!
while : ; do
# Check the time...
CURRENT_TIME="$(date +%H:%M)"
if [ "${CURRENT_TIME}" != "${LAST_TIME}" ] ; then
# It changed, draw the clock!
LAST_TIME="${CURRENT_TIME}"
# Start by building a composite of the current screen w/ a clock at the bottom (Kill the undercolor if annoying. Useful when the time changes on the same page).
/mnt/us/usbnet/bin/fbgrab -z 0 - 2>/dev/null | /mnt/us/linkss/bin/convert PNG:- -gravity south -compose src-over -background "#0000" -fill black -font "${CLOCK_FONT}" -undercolor white -gravity south -size "${CLOCK_SIZE}" caption:"${CURRENT_TIME}" -composite -quality 00 -define png:bit-depth=8 /var/tmp/clock.png
# And then print it, without flashing
eips -g /var/tmp/clock.png
# And clean up behind us
rm -f /var/tmp/clock.png
fi
# See you in thirty!
sleep 30
done
return 0
}
# Sneakily launch the clock watch in the background
clock_watch &
echo "* Clock watch backgrounded w/ PID $!"
# See ya'
exit 0
Since I went all the way with IM, it's friggin' expensive, but hey, it works.