Projects/Background Rotate

From Billstron

Jump to: navigation, search

This simple project was inspired by a post on Lifehacker. The idea is to have a dynamic background image of the world changing from day to night. It should work with any distribution of Linux.

2782041344_08a50edb68.jpg


Instructions

The script is very simple. It just uses wget to get the picture from http://www.opentopia.com. It does check to make sure the file was downloaded so that if you are working off-line (heaven forbid) you keep the last downloaded image.

#!/bin/bash
# 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 ;</nowiki>

  1. Download it here, and put it someplace in your home folder. In step 3 I will call this place [path to script].
  2. Modify the WORKING variable to point to the location that you want to download the images to.
  3. Set the cron job:
>> crontab -e
05 * * * * [path to script]/background_rotate.sh
Personal tools