Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How can I change background via AppleScript?

I need to change the desktop picture using a file on the web via AppleScript.I have this which works but I don't know how to change the file path to a website URL:

tell application "Finder"

set desktop picture to {"Macintosh HD:Library:Desktop:Picture1.jpg"} as alias

end tell


I want to set it to an image file on the internet (e.g. http://www.artofadambetts.com/images/postgraphics/downloads/desktopbgs/LeatherHo les-Apple.png)

I'm using Mountain Lion 10.8


🙂

iMac, OS X Mountain Lion (10.8.2)

Posted on Jan 2, 2013 1:45 PM

Reply
6 replies

Jan 2, 2013 3:07 PM in response to marco2011

You can't change your background to a file on the internet, only a local file (what would happen, for example, if you weren't connected to the internet?)


The simple soluton is to download the image to your system (which you can do any number of ways via AppleScript) and then use your existing AppleScript to set the desktop to the newly-downloaded file.


do shell script "/usr/bin/curl -o ~/Desktop/picture1.png http://some.server.net/path/to/image.png"

tell application "Finder"

set desktop picture to file "picture1.png" of (get path to desktop)

end tell

Jan 5, 2013 11:14 AM in response to marco2011

Hi.



marco2011 wrote:


However i noticed that it doesn't work if the option "Change Picture every n minutes" under System Preferences>Desktop & Screen Saver is selected. If this option is selected, the script does download the image, but it does not set it! Is there a way to fix it?



Like this


do shell script "/usr/bin/curl -o ~/Desktop/picture1.png http://some.server.net/path/to/image.png"
if last word of (do shell script "defaults read com.apple.desktop | grep -m1 -o ' Change = .*;'") is not "Never" then
    tell application "Finder" to set desktop picture to file "picture1.png" of (get path to desktop)
end if

How can I change background via AppleScript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.