Posts Tagged 'st2205 picframe keychain temperature weather script bash'

ST2205u keychain photo-frame as a weather station with random Flickr backgrounds

I’ve made a simple bash script to show the current weather using your hacked ST2205u based keychain photo-frame. The script uses AccuWeather service to check the temperature and downloads a random photo from Flickr for background. Then it gets combined using Imagemagick and the result image is being sent to the picframe. It sleeps for 3 minutes and goes again.

You can easily modify the script to include other info – for example, I’ve added a line showing current date/time to know if it’s still working as when it crashes or stops, the last sent photo remains on the screen.

The script requires: setpic, Curl, Perl, Imagemagick. Tweak DEV=… SETPIC=… and location code first.

This is how it looks like:

#AccuWeather (r) RSS weather tool for conky source:
#Flickr (r) script source:
while true; do
wget $BASEURL -O index.html 2>/dev/zero
URL=`grep 'span class="photo_container pc_t">' index.html |grep jpg|xargs -n1|grep static|cut -d"'" -f6|xargs -n1 echo $BASEURL/|sed s/\ thu/thu/|head -n1|tail -c63|sed s/_t.jpg/_m.jpg/`
if [ "$OLDURL" != "$URL" ]
wget $URL -O - 2>/dev/zero >pict.jpg
convert -gravity Center -resize x128 -resize '128x<' -crop 128x128+0+0 +repage pict.jpg pict.png
rm index.html
`curl -s\?metric\=${METRIC=1}\&locCode\="EUR|PL|PL|Cracow" | 
perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }' > ./weather.txt 2>/dev/zero`
TMP=`cat ./weather.txt | grep -o -P '.{0,0}:.{0,4}' | tr -d ["C: "]`
DATE=`date | sed 's/.\{8\}$//'`
convert -pointsize 40 -style Normal -size 100x100 xc:none -gravity center \
-stroke black -strokewidth 2 -annotate 0 "$TMP"°C \
-background none -shadow 100x3+0+0 +repage \
-stroke none -fill white     -annotate 0 "$TMP"°C \
-pointsize 10 -gravity South -stroke black -strokewidth 2 -annotate 0 "$DATE" \
-pointsize 10 -gravity South -stroke none -fill white     -annotate 0 "$DATE" \
pict.png  +swap -gravity center -geometry +0+0 \
-composite  pict.png
rm weather.txt
$SETPIC $DEV pict.png >/dev/zero
sleep 180


Linux related stuff and more. Yay!