Skip to content

Instantly share code, notes, and snippets.

@jamesnvc
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesnvc/061e5a480af8944565f8 to your computer and use it in GitHub Desktop.
Save jamesnvc/061e5a480af8944565f8 to your computer and use it in GitHub Desktop.
set spacenumber to 9
tell application "System Events"
set _desktops to every desktop
if (count of _desktops) > 1 then
-- if you have multiple displays (eg: external monitor) ask which
display dialog "Choose your screen." buttons (get display name of every desktop) default button 1
set _display to the button returned of the result
else
-- else set the one display as selected
set _display to display name of the first desktop
end if
set new_file to choose file with prompt "Choose an image."
repeat with i from 0 to (spacenumber - 1)
delay 1
tell (every desktop whose display name is _display) to set picture to new_file as alias
tell process "WindowServer" to key code {124} using {control down, command down} -- Go to the next space
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment