Introduction: NASA Astronomy Picture of the Day

SPAAAAAAAAAAACE! Our universe is pretty frickin' great, isn't it? Celebrate the vast awesomeness that we live in by setting your wallpaper to the NASA Astronomy Picture of the Day!

Step 1: What Is This APOD?

The NASA APOD (Astronomy Picture of the Day) is a site where NASA uploads a new space picture each day, complete with a nifty description. They also keep an archive of all of their pictures (going all the way back to June 16th, 1995!).

Step 2: Time for Some Script-fu!

EDIT: I fixed a bug with the picture downloading, but not setting as the Desktop picture. I added the line "killall Dock;" to refresh Finder and display the new homework.

I'd been visiting the page at least once a day for a while before I realized that I could write a simple script to set it as my wallpaper each day. An hour of coding and debugging (BASH isn't my favorite...) later, I was finished! Here is the fruit of my efforts!

Copy the following into a text editor and save as getApod.command to your Desktop (sorry! My computer doesn't seem to like uploading the file!)

#!/bin/bash
#script to download today's NASA Astronomy Picture of the Day and set it as the wallpaper

cd ~/nasapics;
wget -N http://apod.nasa.gov/apod/astropix.html;
wget -N -O todaysImage.jpg http://apod.nasa.gov/apod/$(grep -o "image.*\.jpg" astropix.html | head -n1);
osascript -e 'tell application "Finder" to set desktop picture to "Hard Drive:Users:<YOUR NAME>:nasapics:todaysImage.jpg" as alias';
killall Dock;

PS This script only works for macs ATM, because it uses AppleScript to set the desktop picture. Hopefully theres a Linux wizard out there who could fix up something...)

To set up the script for your computer, just follow these simple steps:
1. Make a new folder in your home directory called nasapics (/Users//nasapics)
2. Change path in the line that says "osascript -e 'tell application "Finder" to set desktop picture to "Hard Drive:Users:<YOUR NAME>:nasapics:todaysImage.jpg" as alias';" to reflect the location of the nasapics folder on your hard drive
       NOTE: Because the script is in a .command file, it will open automatically in Terminal when you double click it. Right click and use "Open With" to select your favorite text editor

To pretty it up a little, move the script to to your desktop, then right click -> Get Info. Copy the NASA logo on this page, then double click on the icon in the top-left (as shown in the picture below) until it gets a blue outline. Then CMD-V to paste the logo there. TADAH!

Step 3: Using the Script

Every morning, just double click the script! It's easy. If you want to hang on to yesterday's picture, don't click the script, if you want something new, click the script!

NOTE: You might get an error if you first use this script when the APOD is not a picture (sometimes its a video). In that case, just wait a day, and you should be good to go!

Step 4: How Does It Work?

The script is pretty simple. It has a couple of steps

1. Make the nasapics folder the working directory
2. Use wget to download the html for the APOD page, use grep to search for the link to the image, and wget again to download the image from that link.
3. Use AppleScript to set the wallpaper

Comments

About This Instructable

7,754views

13favorites

License:

More by britknight:Wii Nunchuck Controlled TurretNASA Astronomy Picture of the DayPlanetary Motion Paperweight
Add instructable to: