|
|
@@ -0,0 +1,59 @@ |
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
REMOTE='http://localhost:8080' |
|
|
|
INTERVAL=1 |
|
|
|
|
|
|
|
requirecmd() |
|
|
|
{ |
|
|
|
which "$1" 2>1 > /dev/null |
|
|
|
if [ "$?" -ne 0 ]; then |
|
|
|
echo "Missing command: $1" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
requirecmd curl |
|
|
|
requirecmd fbv |
|
|
|
requirecmd shasum |
|
|
|
|
|
|
|
calchash() |
|
|
|
{ |
|
|
|
shasum --algorithm 1 "$1" 2>/dev/null | cut -d ' ' -f 1 |
|
|
|
} |
|
|
|
|
|
|
|
PICFILE="pic" |
|
|
|
PICHASH=$(calchash "$PICFILE") |
|
|
|
PROGPID=$$ |
|
|
|
|
|
|
|
# Loop responsible for requesting to the server |
|
|
|
# and updating the picture if necessary |
|
|
|
requestloop() |
|
|
|
{ |
|
|
|
while :; do |
|
|
|
URL="$REMOTE/$PICHASH" |
|
|
|
curl --silent "$URL" > refresh |
|
|
|
|
|
|
|
# Empty response means the file hasn't changed |
|
|
|
if [ $(file refresh | cut -d ' ' -f 2) = "empty" ]; then |
|
|
|
rm refresh |
|
|
|
|
|
|
|
# If the response is non-empty, we received an image file. |
|
|
|
# We move that file to $PICFILE, then display it |
|
|
|
else |
|
|
|
mv refresh "$PICFILE" |
|
|
|
PICHASH=$(calchash "$PICFILE") |
|
|
|
pkill --parent "$PROGPID" fbv |
|
|
|
fi |
|
|
|
sleep "$INTERVAL" |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
requestloop & |
|
|
|
|
|
|
|
while :; do |
|
|
|
if [ -f "$PICFILE" ]; then |
|
|
|
fbv --noclear --noinfo "$PICFILE" |
|
|
|
else |
|
|
|
sleep 2; |
|
|
|
fi |
|
|
|
done |