Use an AppleScript to force a desktop picture change

Jun 11, '08 07:30:00AM

Contributed by: musselrock

I have my desktop images set to change every 30 minutes in random order. Sometimes the desktop will display an image that displayed earlier in the day, and I wanted a way to 'advance' the image easily. The following AppleScript will cause the desktop image to change, in whatever order you have set, each time it is run:

property theSwitch : 0
if theSwitch = 0 then
  tell application "System Events"
    tell current desktop
      set change interval to 1801.0
    end tell
  end tell
  set theSwitch to 1
else
  tell application "System Events"
    tell current desktop
      set change interval to 1800.0
    end tell
  end tell
  set theSwitch to 0
end if
To maintain your current change interval, modify the change interval lines to reflect your interval, measured in seconds. Thus, for my 30-minute setting, I used 1801 and 1800 seconds. One hour would be 3601 and 3600, etc. For this script to work, you must have both Change Picture and Random Order enabled on the Desktop tab of the Desktop & Screen Saver System Preferences panel.

[robg adds: This works as described, and is also useful if you just don't happen to like whatever image was randomly chosen. Save the script as an application and drop it somewhere easy to access for a one-click solution. In my case, I put it into a Butler AppleScript action, and assigned it a keyboard shortcut for a no-click solution. I had to change the script somewhat to make it work in Butler, and my image actually toggles twice -- I basically had to remove all the theSwitch references and loops, leaving just two tell application loops.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080610081312728