How to change desktop background in AppleScript in 10.7?
I'm just now upgrading from 10.6 to 10.7, and I'm having trouble with a script that I wrote that worked fine under 10.6. In part, it executes the following command:
osascript -e "tell application \"Finder\" to set destop picture to POSIX file \"<path>\""
to change the desktop background image to one of two different files based on other conditions.
In 10.7, this command completes with no error code, but it only changes the background of one of my four desktops. Is there a way to programmatically change the background image of all of my desktops simultaneously? Failing that, is there a way to a) find out how many desktops I have and b) loop through them, setting each of their backgrounds in turn?
I did search the web and found the following suggestion:
osascript -e "tell application \"System Events\" to set picture of every desktop to \"<path>\""
Unfortunately, that also changes only the current desktop's picture.
The larger script is in Perl, so I'd prefer a technology that works well with that language, but if I have to change to a different scripting language, that's not the end of the world.
Thanks much for any suggestions!
Richard