backgroundapplescriptdesktopfadewallpaper

Fade Desktop Wallpaper in Applescript (Mac OS X)


I have written an AppleScript which, among other things, sets my desktop background. However, using AppleScript's "set picture" changes the background abruptly - it doesn't look too good. Is there a way to get the nice fade effect that is used when you cycle the background via the Desktop & Screen Saver preferences' "Change Picture" setting?

Ideally, I'd like to do this in AppleScript, but if it's possible in Cocoa (or something else), please do let me know! Thanks!


Solution

  • Answering my own question!

    It's not exactly what I was looking for, but close enough:

    set picture rotation to 1 -- turn on wallpaper cycling
    set change interval to -1 -- force a change to happen right now
    delay 1.5 -- wait a bit to allow for the fade transition - you may want to play w/ this #
    set picture of item N of theDesktops to POSIX file ("yourfilenamehere.png") -- set wallpaper to wallpaper you want
    set picture rotation to 0  -- turn off wallpaper cycling
    

    By taking advantage of Apple's built-in wallpaper changer, you can get the fade effect in AppleScript, but you'll need to put whatever images you want to change between in a directory together and select it either in the Desktop & Screen Saver preferences or programmatically.

    Also, set picture rotation to 1 seems to automatically change the wallpaper to what I think is the first image (alphabetically) in that directory - I didn't bother to test this, though, it didn't matter for my purposes. The delay of 1.5 allows for a bit of blinking, but since the image I was using was a TARDIS, that's acceptable and actually made for a cool effect (so long as we watch out for weeping angels!)