Last active
February 5, 2023 20:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
Export the script as an application bundle and set it as a login item. This way the picture will change automatically on login.
Be sure to uncheck "Change picture" checkbox in desktop background settings for both monitors.