-
-
Save pgib/2778272 to your computer and use it in GitHub Desktop.
Automatically download NASA Astronomy Pictures of the Day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run at 12 o'clock every day | |
0 0 * * * ~/Pictures/Wallpapers/apod/apod.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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