Created
December 26, 2011 15:50
-
-
Save Tasssadar/1521470 to your computer and use it in GitHub Desktop.
This script will periodicaly try to download newest xkcd comic strip and put it into /mnt/us/screensaver, so it will show as screensaver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script will periodicaly try to download newest xkcd comic strip | |
# and put it into /mnt/us/screensaver, so it will show as screensaver | |
# It is for Kindle 4 and requires screensaver hack | |
lastVer=0 | |
w=0 | |
h=0 | |
while :; do | |
echo "check" | |
rm /tmp/xkcd &> /dev/null | |
wget "http://xkcd.com/info.0.json" -O /tmp/xkcd | |
if [ ! -f /tmp/xkcd ]; | |
then | |
sleep 60 | |
continue | |
fi | |
IMG=`cat /tmp/xkcd | awk -F=":" -v RS="," '$1~/"img"/ {print}' | grep -o http:.*.png | sed -e 's%\\\\%%g'` | |
if [ $lastVer != 0 ]; | |
then | |
nowVer=`cat /tmp/xkcd | awk -F=":" -v RS="," '$1~/"num"/ {print}' | grep -o '[0-9].*'` | |
if [ $nowVer == $lastVer ]; | |
then | |
echo "already newest version" | |
sleep 60 | |
continue | |
fi | |
fi | |
rm /tmp/xkcd.png &> /dev/null | |
echo wget $IMG -O /tmp/xkcd.png | |
wget $IMG -O /tmp/xkcd.png | |
if [ ! -f /tmp/xkcd.png ]; | |
then | |
sleep 60 | |
continue | |
fi | |
cp /tmp/xkcd.png /mnt/us/screensaver/ | |
sync | |
lastVer=`cat /tmp/xkcd | awk -F=":" -v RS="," '$1~/"num"/ {print}' | grep -o '[0-9].*'` | |
eips 15 39 "XKCD comic $lastVer downloaded" | |
echo $lastVer | |
sleep 60 | |
# i=0 | |
# in_w=16 | |
# in_h=20 | |
# shift=24 | |
# while [ $i -lt 4 ]; do | |
# width=`hexdump -e '/1 "%u"' -n 1 -s $in_w /tmp/xkcd.png` | |
# let "w = w | ($width << $shift)" | |
# height=`hexdump -e '/1 "%u"' -n 1 -s $in_h /tmp/xkcd.png` | |
# let "h = h | ($height << $shift)" | |
# let "shift -= 8" | |
# let "i +=1" | |
# let "in_w += 1" | |
# let "in_h += 1" | |
# done | |
# echo $w | |
# echo $h | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment