#! /usr/bin/ruby -w # == Synopsis # Ruby script to set x backgrop to NASA image of the day # # == Author # Matt Foster # # == Copyright # Copyright (c) 2006 Matt Foster # Licensed under the same terms as Ruby. require 'rss/2.0' require 'rss/1.0' require 'rss/image' require 'open-uri' require 'rdoc/usage' URL = 'http://www.nasa.gov/rss/lg_image_of_the_day.rss' PREFIX = File.expand_path('~/stuff/backdrops') DESAT = true #bkg_cmd = 'gconftool -t str -s /desktop/gnome/background/picture_filename' bkg_cmd = 'feh --bg-scale' if __FILE__ == $0 if ARGV.length != 0 RDoc::usage exit end open(URL) do |http| response = http.read result = RSS::Parser.parse(response) # Parse image url from feed im_uri = result.image.url image = open(im_uri).read im_name = File.join(PREFIX, File.basename(im_uri)) file = File.new(im_name, 'w') file.write(image) # Desaturate? system("mogrify -modulate 100,20 -resize 1280x1024 #{im_name}") if DESAT