HOWTO: Astronomy Picture of the Day for GNOME
Astronomy Picture of the Day is a really neat page which is generated daily by NASA. It shows a single picture captured by some NASA-affiliated person and some text to describe it.
These pictures are perfect for desktop backgrounds. There’s a program to automatically set it as the background for Windows, but we Linux, or more specifically, GNOME, users can do it in a simple script.
Drop this script somewhere on your system and create a cron schedule with crontab -e for it. The cron lines are in the script. I’d recommend the four hour intervals if you don’t keep your computer on all the time, or the twelve or once-a-day intervals if you do.
Oh, and you might need to install cron. Gutsy doesn’t have it by default, so you can do it through Synaptic or using sudo apt-get install cron at a command line.
#!/bin/bash
#Filename: apodwallpaper
#Location: ${HOME}/.bin
#Purposes: Downloads NASA Astronomy Picture of the Day and displays it as the
# GNOME background
#Author(s): acvwJosh of Ubuntu Forums, modified by Colin Dean <http://cad.cx>
#add the following line to your crontab if you want to run this hourly
#10 * * * * apodwallpaper
#add this line if you want to run it every four hours
#10 0,4,8,12,16,20 * * * apodwallpaper
#add this line if you want to run it every twelve hours
#10 0,12 * * * apodwallpaper
#add this line if you want to run it daily
#10 0 * * * apodwallpaper
#don't forget to put this script in your $PATH.
#I usually add ${HOME}/.bin to my path in .bash_profile and put my scripts there
#change this if you want the image to be in a different directory
FILENAME=apodwallpaper
APODWALLPAPER=${HOME}/.${FILENAME}
mkdir -p ${APODWALLPAPER} && cd ${APODWALLPAPER}
# download image from apod site
wget -A.jpg -R.txt -r -l1 --no-parent -nH http://antwrp.gsfc.nasa.gov/apod/astropix.html
# move image from obscure folder to main folder, rename image
find ./apod -name "*.jpg" | while read line ; do
mv "$line" "${FILENAME}.jpg"
done
# set image to wallpaper
gconftool-2 -t string -s /desktop/gnome/background/picture_filename "blank.jpg"
gconftool-2 -t string -s /desktop/gnome/background/picture_filename \
"${APODWALLPAPER}/${FILENAME}.jpg"
gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"
#get rid of cruft
rm -rf apod robots.txt
There’s a thread about this functionality at Ubuntu Forums entitled, APOD? anyone.


Leave a comment