Skip to content

Instantly share code, notes, and snippets.

@mgunneras
Created December 2, 2009 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgunneras/247112 to your computer and use it in GitHub Desktop.
Save mgunneras/247112 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Run as cronjob to have a daily fresh desktop
# background from the NASA Image of the day gallery.
# You might need to install BeautifulSoup and appscript
# easy_install BeautifulSoup appscript
from os.path import basename
from BeautifulSoup import BeautifulStoneSoup
from appscript import app, mactypes
from urllib2 import urlopen
rss_url = 'http://www.nasa.gov/rss/lg_image_of_the_day.rss'
image_url = BeautifulStoneSoup(urlopen(rss_url).read()).find('url').string
image_path = "/%s" % basename(image_url)
open(image_path, 'w').write(urlopen(image_url).read())
app('Finder').desktop_picture.set(mactypes.File(image_path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment