Skip to content

Instantly share code, notes, and snippets.

@Lerg
Last active February 5, 2023 20:57
Show Gist options
  • Save Lerg/322537d2e694cf704aa824b31b7dbe2e to your computer and use it in GitHub Desktop.
Save Lerg/322537d2e694cf704aa824b31b7dbe2e to your computer and use it in GitHub Desktop.
macOS AppleScript to set the same random picture as a desktop background on all monitors. Pictures are taken from the `~\Pictures` directory.
tell application "Finder"
set randomimage to some file of folder ((path to home folder as string) & "Pictures") as string
end tell
tell application "System Events"
tell every desktop
set random order to false
set picture to randomimage
end tell
end tell
@fpuhan
Copy link

fpuhan commented Feb 5, 2023

I was looking for a way to do this! macOS Ventura (13.2) seems to have broken a lot of things in AppleScript. When I run this on my Mac, I get a desktop picture change, but it's not coming from the folder I specified. I have a "Deskpics" folder inside my Documents folder, but when I change the code to

set randomimage to some file of folder ((path to home folder as string) & "Documents:Deskpics") as string

I still get files from (apparently) the last folder used in my System Settings.

I haven't found any release notes from Apple or updated documentation on the changes to AppleScript in macOS Ventura, and I know I'm not alone in this. I wonder if Apple is dropping support for AppleScript?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment