Created
December 30, 2008 21:38
-
-
Save ehrenmurdick/41766 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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} | |
This file contains 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
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