The scripting and programming is mostly complete. Time to test the Kindle. For the purpose of testing, I set the Kindle to change screensavers every 5 minutes instead of every 3 hours. It works flawlessly for hours at a time, then fails. It always fails in the same way: displaying no picture in screensaver mode. Even manually pressing the button power twice does not solve it. Perhaps the Blanket program crashed or something, I don't know, but it fixes itself after a restart.
After hours of debugging I still cannot figure out what the problem is. Decided to call it quits, but added a recovery option should that happen. I installed KUAL and kterm, so that after a reboot I can manually run my screensaver changing script again.
Finally, I decided to consolidate both the script to change screensavers and that to download images. Here's the final masterpiece:
# time to wake up | |
lipc-set-prop com.lab126.powerd wakeUp 1 | |
sleep 3 | |
mntroot rw | |
# download new images | |
lipc-set-prop com.lab126.cmd wirelessEnable 1 | |
sleep 20 | |
url=http://yourOwnURLhere.com | |
rm index | |
wget $url/images/index || error_exit "Cannot download list of images!" | |
grep "/img/uploads" index | awk -F\" '{print $2}' > /mnt/us/images.txt | |
cd pics | |
while read line | |
do | |
wget $url$line | |
done < /mnt/us/images.txt | |
# mark all images as downloaded | |
wget $url/images/reset | |
rm reset | |
lipc-set-prop com.lab126.cmd wirelessEnable 0 | |
# randomize current set of photos | |
for f in /mnt/us/photos/* | |
do | |
newfile=`mktemp -p /mnt/us/photos` | |
mv -f $f $newfile | |
done | |
# if pics are downloaded, then choose between a pic and a photo | |
if [ "$(ls -A /mnt/us/pics)" ] | |
then | |
# 50% probability of displaying pic or photo | |
if [ `sed 's/[^[:digit:]]\+//g' < /dev/urandom | head -n 1 | awk '{print substr($0,0,2);}'` -lt 50 ] | |
then | |
# display a downloaded pic | |
echo displaying a downloaded pic | |
mv -f "/mnt/us/pics/`ls /mnt/us/pics -1 | head -n 1`" /mnt/us/linkss/screensavers/bg_xsmall_ss00.png | |
else | |
# display a photo | |
echo displaying a photo | |
cp "/mnt/us/photos/`ls /mnt/us/photos | sort | head -n 1`" /mnt/us/linkss/screensavers/bg_xsmall_ss00.png | |
fi | |
else | |
# no pics currently, just change to a photo | |
cp "/mnt/us/photos/`ls /mnt/us/photos | sort | head -n 1`" /mnt/us/linkss/screensavers/bg_xsmall_ss00.png | |
fi | |
/usr/bin/powerd_test -p | |
a=0 | |
while [ $a -lt 50 ] | |
do | |
lipc-set-prop com.lab126.powerd deferSuspend 86400 | |
sleep 2 | |
a=`expr $a + 1` | |
done |
I've reset the screensavers to change every 3 hours instead of 5 minutes. It'll still be a few days before I present this to my girlfriend, a final few days to test and make sure it works perfect!
No comments:
Post a Comment