DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Set Desktop Background Droplet

  • submit to reddit
        -- This script should be run as a droplet
-- It expects that an image is dropped on it's icon

-- The on run handler is called if the user has double clicked the icon
on run
	display dialog "Please drop an image file on this Icon to set it as the desktop background"
end run

-- The on open handler is called when the user drags and drops  afile on the icon
on open draggeditems
	set imageFile to last item of draggeditems
	tell application "Finder"
		select window of desktop
			set desktop picture to file (imageFile as text)
		on error
			display dialog "Invalid image file."
		end try
	end tell
end open