Saturday, June 11, 2011

timbit! Simple bash script to get NASA's Astronomy Picture of the Day

  1. Add this script to your crontab (I run it hourly)
  2. Set your wallpaper preference to ~/images/wallpapers/apod.jpg (or edit APOD_FILE below)
  3. The next time you log in the new image will appear
#!/bin/bash

BASE_URL=http://apod.nasa.gov/apod/
PAGE_URL=${BASE_URL}/astropix.html
APOD_FILE=~/images/wallpapers/apod.jpg

wget -qO - ${PAGE_URL} | grep "IMG" | \
    wget -qO ${APOD_FILE} \
    ${BASE_URL}`awk -F "\"" '{print $2}'`

No comments:

Post a Comment