Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set desktop photo from applescript in os x mavericks (10.9)

I am trying to set the desktop picture in OS X with applescript. This code worked in 10.6-10.8 but is broken in Mavericks (10.9).

tell application "System Events"
    tell current desktop
        set picture to POSIX file "/development/desk/x.jpg"
    end tell
end tell

I know they changed how multiple monitors are supported but I am not sure what might have broken this.

like image 303
jimmy Avatar asked Oct 20 '22 22:10

jimmy


1 Answers

Thanks to this github project this works. Perhaps the idea of a default desktop does not exist in 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
like image 141
jimmy Avatar answered Oct 24 '22 01:10

jimmy