Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c5adc505d7
Fetching contributors…

Cannot retrieve contributors at this time

executable file 33 lines (26 sloc) 1.058 kB
#!/home/gregf/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
# vim: set sw=2 sts=2 et tw=80 :
WALLPAPER="/home/gregf/media/wallpaper/new/" # Full path no ~
IMAGE_FORMATS="[.jpg,.gif,.png,.bmp]" # Keep this a string
WALLPAPER_CMD="/usr/bin/feh" # Whatever command you use to set your wallpaper
WPCMD_OPTIONS="--bg-scale" # Any options you need to pass to the above command
DISPLAY=":0.0" # You can use ENV['DISPLAY'] here but, it wont work from a cronjob.
unless IMAGE_FORMATS.class == String
puts "IMAGE_FORMATS must be a string, surround it in quotes."
exit
end
unless File.directory?("#{WALLPAPER}")
puts "Wallpaper directory #{WALLPAPER} does not exist"
exit
end
unless File.executable?("#{WALLPAPER_CMD}")
puts "#{WALLPAPER_CMD} is not executable"
exit
end
ENV["DISPLAY"] = "#{DISPLAY}"
Dir.chdir("#{WALLPAPER}") do
files = Dir.glob("*#{IMAGE_FORMATS}")
#puts random_file = rand(1-files.size) # 1.8.6
random_file = Random.new.rand(1..files.size) # requires ruby 1.9.2
IO.popen("#{WALLPAPER_CMD} #{WPCMD_OPTIONS} #{files[random_file]}")
end
Jump to Line
Something went wrong with that request. Please try again.