#!/bin/bash # Updates destop background to one of several continuously updated photos. # Maintains a file called $PREFIX(timestamp).jpg in ~/Pictures. # Allows for an image to be composited via Imagemagick # A filename prefix that won't conflict with anything already in ~/Pictures PREFIX='GOES' # path to identify, mogrify, and composite executables (ImageMagick) ID='/sw/bin/identify' MOG='/sw/bin/mogrify' COMP='/sw/bin/composite' function help () { NM=$(basename $1) echo " sets desktop background to a satellite image (with optional overlay)" echo echo " use: $NM [-c|-f|-i|-m|-v|-w] [overlay file] [composite style]" echo " -c GOES east coast color composite (15 mins)" echo " -f GOES west hemisphere full disk (3 hrs)" echo " -i GOES east coast IR (30 mins)" echo " -m die.net mercator full earth (3 hrs)" echo " -v GOES east coast vis (30 mins)" echo " -w weather.com current weather (?)" echo echo " overlay file:" echo " requires ImageMagick" echo " resizes to width of downloaded image" echo echo " composite style:" echo " default: multiply" echo " available: clear, src-over, dst-over, src-in, dst-in, src-out," echo " dst-out, src-atop, dst-atop, xor, plus, multiply," echo " screen, overlay, darken, lighten, color-dodge," echo " color-burn, hard-light, soft-light, difference," echo " exclusion" exit } case $1 in -b) PIC='http://goes.gsfc.nasa.gov/goescolor/goeseast/hurricane2/color_lrg/latest.jpg';; -c) PIC='http://goes.gsfc.nasa.gov/goescolor/goeseast/hurricane2/color_med/latest.jpg';; -f) PIC='http://www.goes.noaa.gov/FULLDISK/GEVS.JPG';; -i) PIC='http://www.goes.noaa.gov/GIFS/ECIR.JPG';; -m) PIC='http://static.die.net/earth/mercator_1600.jpg';; -v) PIC='http://www.goes.noaa.gov/GIFS/ECVS.JPG';; -w) PIC='http://image.weather.com/images/maps/current/curwx_600x405.jpg';; *) help $0;; esac # for crontab [ "$(uname)" == "Darwin" ] && PATH=$PATH:/sw/bin/ NEW="$PREFIX$(date +%s)" curl -s -m 40 $PIC 2>/dev/null > ~/Pictures/$NEW [ $? == "0" ] || { rm ~/Pictures/$NEW 2>/dev/null exit } rm ~/Pictures/$PREFIX[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].jpg 2>/dev/null mv ~/Pictures/$NEW ~/Pictures/$NEW.jpg [ $2 ] && { W1=$($ID ~/Pictures/$NEW.jpg | awk '{split($3,a,"x"); print a[1]}') cp $2 /tmp/$$ [ "W1" != "$($ID $2 | awk '{split($3,a,"x"); print a[1]}')" ] && $MOG -scale $W1 /tmp/$$ if [ ! $3 ];then COMPOSITE='multiply'; else COMPOSITE=$3; fi $COMP -compose $COMPOSITE -gravity SouthEast /tmp/$$ ~/Pictures/$NEW.jpg ~/Pictures/$NEW.jpg rm /tmp/$$ } [ "`uname`" == "Linux" ] && { # resizing stuff $MOG -resize 2560 ~/Pictures/$NEW.jpg && $MOG -crop 2560x1024+0+100 ~/Pictures/$NEW.jpg #feh --bg-center ~/Pictures/$NEW.jpg xsetbg ~/Pictures/$NEW.jpg } [ "`uname`" == "Darwin" ] && osascript -e "tell application \"Finder\" to set desktop picture to file \"$NEW.jpg\" in (path to pictures folder)"