Reputation: 925
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!
Upvotes: 0
Views: 1293
Reputation: 532
The original question is more than ten years old, but I suppose it still makes sense to post another contribution — after all I ran into this article because I was searching for it.
After playing with AppleScript I wasn't able to find any satisfactory solution. So I used an alternate approach: let the system do its job as usual without tweaking with it, but changing the images it manages on the fly.
In other words: assuming that $TEMP_WALLPAPER_FOLDER
is an empty working folder, I configured System Preferences to use it as the folder with background pictures, I disabled random order and set to change background every 5 seconds.
Then this little piece of bash
script, called every five minutes, does the job. Assuming that $IMAGE
is the new image to use:
$IMAGE
to the temporary folder with a link whose name is the current timestamp (it isn't necessary to have a timestamp, a progressive index would do, but a timestamp is easier to manage); at this point there are two links in the folder, the previous image and the new one. TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
ln -fs "$IMAGE" "$TEMP_WALLPAPER_FOLDER/$TIMESTAMP.jpg"
sleep 8
find "$TEMP_WALLPAPER_FOLDER" -type l | grep -v "$TIMESTAMP" | xargs rm
Upvotes: 0
Reputation: 925
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!)
Upvotes: 1