Journal

By Steve Challis

Recent Entries

Archive

RSS/Atom

Home

Projects

@schallis

NASA Astronomy Picture of the Day Background

2 years, 2 months ago — 1509 Comments — Permalink

  • nasa
  • astronomy
  • script
  • bash

Update: An improved version of this script now lives on Github Gist at https://gist.github.com/1144996

NASA have this really neat Astronomy Picture of the Day webpage with some incredible pictures. I thought it’d be neat to set these as my desktop background picture so wrote the following script to accomplish this. It basically downloads the most recent picture to whatever folder you put it in and will wipe the folder whenever run. Adding this to a daily cron and then setting your desktop background to image.jpg should give you a changing picture.

#!/bin/sh
dst=`dirname $0`
base="http://apod.nasa.gov"
rm -rf $dst/*.jpg
wget -qO- http://apod.nasa.gov/apod.rss |
    grep "link" | head -n 1 |
    sed "s/.*<link>\(.*\)<\/link>.*/wget -qO- \1/" | bash - |
    grep "href=\"image" | head -n 1 |
    sed "s;.*\"\(.*\)\".*;wget -O $dst/image.jpg $base/\1;" | bash -

The accompanying crontab entry will be something along the lines of:

0   0   *   *   *   ~/Pictures/Wallpapers/apod/getpic.sh
« NewerOlder »

Log in

Powered by Mumblr – a basic Django tumblelog application that uses MongoDB with MongoEngine. Fork it on Github. Designed and developed by Harry Marr and Steve Challis.

Unless otherwise noted, everything here is available under the Creative Commons Attribution-Share Alike 3.0 license. Sharing is fucking cool.

Home / Projects / Recent / Archive / RSS /