#!/bin/bash
# Downloads the day/night image of the world and sets it as the background.  
# Instructions:
#	Place this script someplace in your home.  
# 	Modify WORKING to point to the directory you want the images downloaded to.
#	Set the cron job as such:
#			05 * * * * [path to script]/background_rotate.sh
#		replacing [path to script] with the path to the script.
# Created on 8/19/2008 by billstron (www.billstron.com)


# Where you want the images stored.  
WORKING="/home/bill/Pictures/wallpaper";

# Change directories to the working directory. 
cd $WORKING;

# Move the old one over if it exists
if [ -e $WORKING/world_sunlight_map_rectangular.jpg ]; then #File is there
	mv $WORKING/world_sunlight_map_rectangular.jpg   \
		$WORKING/world_sunlight_map_rectangular_old.jpg ;
fi
	
# Get the background image of the day/night world.
wget http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg  \
	-o $WORKING/log.txt -T 10 ;

# If it wasn't retrieved, move the old one back
if [ ! -f $WORKING/world_sunlight_map_rectangular.jpg ]; then #File is there
	mv $WORKING/world_sunlight_map_rectangular_old.jpg   \
		$WORKING/world_sunlight_map_rectangular.jpg ;
fi

# Set the image as the background.  
gconftool-2 --type string --set   \
	/desktop/gnome/background/picture_filename  \
	$WORKING/world_sunlight_map_rectangular.jpg ;

