Skip to content

Instantly share code, notes, and snippets.

@ehrenmurdick
Created December 30, 2008 21:38
Show Gist options
  • Save ehrenmurdick/41766 to your computer and use it in GitHub Desktop.
Save ehrenmurdick/41766 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
COLOR_FILE = '/Users/ehrenmurdick/bin/config/desktop-color'
require 'color'
require 'rmagick'
include Magick
if File.exist?(COLOR_FILE)
color = Marshal.load(File.open(COLOR_FILE).read)
else
color = Color::HSL.new(0, 60, 40)
end
color.hue += 2
File.open(COLOR_FILE, 'w') {|f| f.write(Marshal.dump(color)) }
image = Image.new(100, 100)
rgb = color.to_rgb
p = Pixel.new(rgb.red, rgb.green, rgb.blue)
image = image.color_floodfill(1, 1, p)
name = "#{COLOR_FILE}-1.png"
image.write(name)
name = "#{COLOR_FILE}-2.png"
image.write(name)
%x{osascript /Users/ehrenmurdick/bin/update-desktop.scpt}
%x{echo #{Time.now} > /Users/ehrenmurdick/bin/config/color-changed-at}
set thePic1 to POSIX file "/Users/ehrenmurdick/bin/config/desktop-color-1.png"
set thePic2 to POSIX file "/Users/ehrenmurdick/bin/config/desktop-color-2.png"
tell application "Finder" to set the desktop picture to thePic1
tell application "Finder" to set the desktop picture to thePic2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment