Updating desktop background

First I attempted some trickery where I pointed the OS X desktop to a dedicated folder in which it would find one (or two, one being a symlink) file that regularly found itself replaced with a fresh version; This seemed to cause problems, somehow, as I’ve never seen the dock (crash, I assume, and) restart so many times in 72 hours.

A much more elegant solution is to use a bit of AppleScript magic:

/usr/bin/osascript <<END
tell application "Finder"
        set pFile to POSIX file "$1" as string
        set desktop picture to file pFile
        end tell
END

My thanks to Harold Bakker who wrote this script. It was written as a learning exercise in (perl and) osascript for him, and it taught me a new trick as well.