I have this working script that changes the Desktop picture on the currently active screen on all connected monitors.
The problem is that it won’t iterate over all the other spaces on each monitor. Does anyone know if there is a way to get a list/array of all the spaces from each screen in NSScreens?
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
use framework "AppKit"
property NSWorkspaceDesktopImageScalingKey : a reference to current application's NSWorkspaceDesktopImageScalingKey
property NSWorkspace : a reference to current application's NSWorkspace
property NSURL : a reference to current application's NSURL
property NSScreen : a reference to current application's NSScreen
property NSDictionary : a reference to current application's NSDictionary
property NSNumber : a reference to current application's NSNumber
set theWorkspace to NSWorkspace's sharedWorkspace()
set theImage to NSURL's fileURLWithPath:"/absolute/path/to/your.png"
set theScreens to (NSScreen's screens()) as list
set aNum to NSNumber's numberWithInt:1 -- stretch to fill
set aDict to NSDictionary's dictionaryWithObject:aNum forKey:NSWorkspaceDesktopImageScalingKey
repeat with i from 1 to count of theScreens
set this_screen to item i of theScreens
(theWorkspace's setDesktopImageURL:theImage forScreen:this_screen options:aDict |error|:(missing value))