Skip to content

Instantly share code, notes, and snippets.

@pgib
Forked from schallis/apod.sh
Created May 23, 2012 22:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgib/2778272 to your computer and use it in GitHub Desktop.
Save pgib/2778272 to your computer and use it in GitHub Desktop.
Automatically download NASA Astronomy Pictures of the Day
# Download the latest pic of the day from NASA and delete or archive any
# previous ones in a specified directory. Optionally create a copy of the most
# current picture to allow OSX to pick up pictures as wallpapers
#
# Steve Challis 2011
# http://schallis.com/2011/mar/20/nasa-astronomy-picture-of-the-day-background/
# Get a fresch picture from NASA
todays_pic=`ruby -rubygems latest_nasa_photo.rb`
if [ -d tmp ]; then
rm -rf tmp
fi
mkdir tmp
cd tmp
curl -O --silent $todays_pic
file=`ls -1 *.jpg`
mv $file ..
cd ..
rm -rf tmp
echo "Setting wallpaper to $file"
osascript -e 'tell application "Finder"' \
-e "set desktop picture to POSIX file \"`pwd`/$file\"" \
-e "end tell"
# Run at 12 o'clock every day
0 0 * * * ~/Pictures/Wallpapers/apod/apod.sh
require 'httparty'
require 'json'
require 'awesome_print'
latest_image = HTTParty.get('http://api.flickr.com/services/feeds/photos_public.gne?id=35067687@N04&lang=en-us&format=rss_200').parsed_response.first[1]['channel']['item'].first['content']['url']
puts latest_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment