4

I have the following code to change the desktop image of my Macbook

tell application "System Events"
tell current desktop
set picture to "/Library/Desktop Pictures/Beach.jpg"
end tell
end tell

How do change all desktops - I have a second monitor.

7

The previous answers look great, but I wanted to share a way I found to do this with much less code.

tell application "System Events"
    tell every desktop
        set picture to "path/to/picture.png"
    end tell
end tell

You could even condense it to one line:

tell application "System Events" to tell every desktop to set picture to "path/to/picture.png"
0
3

Here's a little script I use to set most of the Desktop Background properties for my dual monitors:

tell application "System Events"
    tell desktop 1
        set pictures folder to "/Library/Desktop Pictures"
        set picture rotation to 2 -- using interval
        set change interval to 1800
        set random order to true
    end tell
    tell desktop 2
        set pictures folder to "/Library/Desktop Pictures/Mine"
        set picture rotation to 2 -- using interval
        set change interval to 1800
        set random order to true
    end tell
end tell

I use this because MacOSX often resets my backgrounds to the default.

2

This might work. I only have one monitor so couldn't properly test it.

tell application "System Events"
    set desktopCount to count of desktops
    repeat with desktopNumber from 1 to desktopCount
        tell desktop desktopNumber
            set picture to "/Library/Desktop Pictures/Beach.jpg"
        end tell
    end repeat
end tell
1
  • 1
    Is there a way to set the picture to "dynamic" mode on each desktop as well? For that matter... where is there a reference for all the available settings available for Desktop pictures, Screensavers, etc in AppleScript? – RCross Apr 14 '20 at 8:24
0

For the Default monitor

osascript -e 'tell application "System Events" to set picture of current desktop to "<path-to-img>"'

For the second monitor

osascript -e 'tell application "System Events" to set picture of second desktop to "<path-to-img>"'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .