Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create a range of solid colors for Desktop backgrounds' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a range of solid colors for Desktop backgrounds
Authored by: tedw on Nov 12, '09 05:41:51PM
just because, here's an all-applescript way of tweaking out the 'transparent image' approach (and doing it with some perks):
tell application "System Events"
	set theDesktopPlist to property list file "~/Library/Preferences/com.apple.desktop.plist"
	set theGivenDesktop to property list item "displaycode" of property list item "Background" of theDesktopPlist
		-- replace 'displaycode' with the correct code for your display - see below
	try
		set theColorArray to property list item "BackgroundColor" of theGivenDesktop
	on error
		set theColorArray to make new property list item at end of property list items of theGivenDesktop with properties {kind:list, name:"BackgroundColor"}
	end try
	repeat with i from 1 to 3
		if not (exists property list item i of theColorArray) then
			make new property list item at end of property list items of theColorArray with properties {kind:number, value:random number}
		else
			set value of property list item 1 of theColorArray to random number
		end if
	end repeat
	set picture of (desktop 1) to file "path:to:transparent_image.png"
end tell
you can set this to run from the script menu, or have launchd run it periodically as you like. basically this modifies the plist file for the correct desktop using random numbers for the RGB values, and then forces the screen to update by reloading the picture. tricky points:
  • You have to figure out the display code for the display in question. the display code is a 9-16 (more or less) digit number; the only place the system makes a connection between display names and display codes is (that I've been able to find) in the invisible ~/Library/Preferences/.GlobalPreferences.plist file, though it's usually easy enough to figure out which is the correct code just by looking at ~/Library/Preferences/com.apple.desktop.plist and experimenting a little
  • You have to make sure that you create the transparent image correctly. if you use a GIF or PNG format and make sure the content is empty (not set to a neutral background color) you'll be fine. Photoshop and GIMP will both do this nicely, and I'm sure there are more lightweight graphics apps for the task as well. I used a 16x16px transparent image just to be sure it was invisible.
I've used a random number here, but it would be easy enough to set up a subroutine for more programmatic choices. the RGB numbers just need to be between 0 (no color) and 1 (full color).

[ Reply to This | # ]