Skip navigation.

Harold's Home

Proudly associated with: Virtual Pet Rock
   Home > Personal > Downloads > APOD to desktop
  
PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies
Virtual Pet Rock

Astronomy Picture Of the Day to Desktop

Today's Astronomy picture

Two scripts that work together to download the astronomy picture of the day (also know as APOD) and set it as the current desktop backgrond in Mac OS X.

HOW IT WORKS
The scripts work by downloading an HTML file, extracting the location of the big version of the daily picture from that and downloading that. That downloaded picture will then be set as the current desktop background using OSAscript, a commandline version of Applescript. After the image file has been set as the current desktop background it will be left in the /tmp directory where you can fish it out for safekeeping if you like.

REQUIRES
Mac OS X
Perl and curl (should be installed already otherwise install the developerstools)

INSTALLING
Download the archive using the download link at the bottom of this page. Unpack this and place both apod.pl and apod.osa.sh in the folder named "bin" inside your home directory (create this folder if necessary) and make them 'executable'.
To make the scripts executable type this in the Terminal:
cd ~/bin; chmod 755 apod.osa.sh apod.pl
Make a cron entry to execute this script every day at a time when you're sure your machine is on, recommended way: Cronnix.
I entered the following in Cronnix:
exec "/Users/harold/bin/apod.pl" >& /dev/null
this command executes the script.

cronnix entry for apod to desktop

KNOWN LIMITATIONS
These scripts work by grabbing the link to the big version of an image, however sometimes the APOD people use flash videos or animated gifs instead of a bigger jpeg picture, these obviously don't work so the script doesn't even try to download these, you'll be forced to look at the picture that was already on your desktop.

A NOTE ABOUT RESTARTING
After a restart your desktop picture may be reset to Apple's default. This is because the downloaded picture is removed from the tmp directory after a restart and OS X doesn't always "remember" the picture. We could change the location of the downloaded picture to somewhere in your home directory but this could mean that your disk would fill up unnoticed. Mac OS X does WEIRD things when a disk is full so by putting the pictures in a directory that gets trimmed every once in a while (either by a restart or by a system cleanup script that runs every day) we prevent all kinds of trouble. This of course means that we'll have to download the picture again after a restart. The safest and most fool-proof way is to just run a small applescript application on login. This application is provided, just put it into your utilities folder and add it to your login items. Personally I haven't seen much problems with this but your mileage may vary.

cronnix entry for apod to desktop

COPYRIGHT
These files are completely free and you may modify them as needed.
Please note that the astronomy pictures of the day that will be downloaded are probably copyrighted.
Please read the section "About image permissions" on http://apod.nasa.gov/apod/lib/about_apod.html.

FINAL DISCLAIMERS
These scripts were made by Harold Bakker as an exercise in using Perl and OSAscript to do something fun in OS X, no infringement of copyright is intended. I make no claims this software will work on your particular configuration. You agree not to hold me responsible for any failings in the workings of this software, whether implied or stated.

Download (32 k). Downloads so far: (older versions: 1856).

XML version of this site
About, copyright, privacy and accessibility | Mail