Applescript to Change Wallpapers in 10.9

Discussion in 'Mac Programming' started by Vandal., Jun 3, 2014.

  1. Vandal. macrumors member

    Vandal.

    Joined:
    Jan 3, 2013
    #1
    Hey guys,

    I used to have ControlPlane change my desktop background when I arrive at the office in Mountain Lion but as they changed the way desktops are handled in Mavericks this script doesn't work anymore:

    Code:
    tell application "System Events"
    	-- SET DESKTOP TO SPECIFIC PICTURE
    	tell (every desktop whose display name is "Cinema Display X")
    		set picture rotation to 0 -- (0=off, 1=interval, 2=login, 3=sleep)
    		set picture to file "Macintosh HD:Users:User:Pictures:Wallpaper:Wallpaper1.jpg"
    	end tell
    	tell (every desktop whose display name is "Color LCD Y")
    		set picture rotation to 0 -- (0=off, 1=interval, 2=login, 3=sleep)
    		set picture to file "Macintosh HD:Users:User:Pictures:Wallpaper:Wallpaper2.jpg"
    	end tell
    end tell
    I understand that HFS paths are not working anymore, but the same script with POSIX paths doesn't work either. Any chance you guys have an idea on how to do this?

    Thanks,
    V
     
  2. AdonisSMU, Jun 8, 2014
    Last edited: Jun 8, 2014

    AdonisSMU macrumors 603

    Joined:
    Oct 23, 2010
    #2
    Maybe make a javascript version. Not sure what changed honestly with this version of Xcode.
     
  3. Partron22, Jun 10, 2014
    Last edited: Jun 10, 2014

    Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #3
    This still works for me (10.9.3):
    Code:
    -- SetDesktopPic
    -- BP Feb, 2011
    
    set tlst to {}
    set newtop to (path to home folder as string) & "Pictures:desktop pics folder:BigDipper 916.jpg" as alias -- sample line
    --set newtop to choose file
    
    
    tell application "System Events"
    	set tlst to a reference to every desktop
    	--set picture of item 1 of tlst to newtop  -- display 1
    	set picture of item 2 of tlst to newtop -- display 2
    end tell
    I've got two monitors, and this script is currently set to change the desktop of monitor two to "BigDipper 916.jpg".

    The commented out bits'll (--) let you set the first monitor's desktop, or choose which image you want to use.
     
  4. Vandal. thread starter macrumors member

    Vandal.

    Joined:
    Jan 3, 2013
    #4
    Thanks a ton Patron, your solution does work! :)
     

Share This Page