arioch1984
8/18/2014 - 1:56 PM

Change all spaces wallpaper at once - OSX mac

Change all spaces wallpaper at once - OSX mac

-- Adapted from http://movingparts.net/2012/09/25/changing-backgroundwallpaper-on-os-x-with-multiple-spaces-and-multiple-monitors/
-- Copied from http://apple.stackexchange.com/questions/61677/changing-desktop-background-in-os-x-10-8-only-changes-it-for-the-current-desktop

-- pick a new background image
set theFile to choose file

-- *Note*: Set the number of spaces/desktops manually
set numSpaces to 12

-- Loop through the spaces/desktops, setting each of their backgrounds in turn:
-- *Note*: Set your keyboard shortcut for desktop 1 if it’s different
tell application "System Events" to key code 18 using {control down} -- ⌃1
repeat (numSpaces) times

    -- Now loop through each monitor (confusingly called desktop) and change its background
    tell application "System Events"
        set monitors to a reference to every desktop
        set numMonitors to count (monitors)
        log numMonitors
        repeat with monitorIndex from 1 to numMonitors by 1
            set picture of item monitorIndex of the monitors to theFile
        end repeat
    end tell

    delay 0.2

    -- switch to the next desktop
    -- *Note:* Set your keyboard shortcut for "next desktop" if it’s different
    tell application "System Events" to key code 124 using {control down} -- ⌃→
    delay 0.2
end repeat