从os x mavericks中的applescript设置桌面照片(10.9)

jim*_*mmy 5 macos applescript

我正在尝试使用applescript在OS X中设置桌面图片.这段代码在10.6-10.8中有效,但在小牛队(10.9)中被打破.

tell application "System Events"
    tell current desktop
        set picture to POSIX file "/development/desk/x.jpg"
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

我知道他们改变了支持多个显示器的方式,但我不确定可能会破坏这个.

jim*_*mmy 3

感谢这个 github 项目,这才有效。也许 10.9 中不存在默认桌面的想法?

    tell application "System Events"
        set theDesktops to a reference to every desktop
        repeat with x from 1 to (count theDesktops)
            set picture of item x of the theDesktops to "/development/desk/x.jpg"
        end repeat
    end tell
Run Code Online (Sandbox Code Playgroud)