Looking for a way to automate changing image shuffle frequency in Tahoe

I have tried many different approaches to solving this problem. I’ve tried a KM only solution, but cannot get the pop-up to work in the the way I’ve done before, clicking on an image. I’ve tried an AppleScript only approach, but even using UI browser, I can’t manipulate the shuffle frequency popup. All I want to do is to select the frequency from the UI in the Wallpaper Preference pane, but whenever I try to set it to some different value, the screen changes, and breaks “Found Image”. I’ve tried positioning via the “Move and Click” KM action, but since generally resolutions on different screens are different, one single solution doesn’t work. So, I’m stumped. Here’s an attempt that doesn’t work, and one that does work, but not for the pane of interest.

My preference is to find a way to do this using Terminal, but I cannot find a command that does what I want. I’m open to suggestions.

Here are two techniques as examples. The first does not work, but the second does something similar for a different preference pane.

ScreenSaver Set Wallpaper Shuffle 15 minutes.kmmacros (8.0 KB)

ScreenSaver Set Display off when inactive.kmmacros (6.3 KB)

I created the attached as an exercise to help me learn more about KM.

It is far from elegant and is very much a brute force approach.

It basically walks through all of the options in the drop down. It will then select the “Every 15 Minutes” entry.

I hope this helps even if it only gives you new ideas on how to address your specific use case with a more programatic approach.

Change Wallpaper Picture Shuffle Frequency.kmmacros (283.6 KB)

It’s an interesting approach. I hadn’t thought about dealing with it this way. I think this is worth exploring. Thank you. I will give it a try.

Of course, I’m sure we can all agree that a way to set the value in a direct, programatic way would be much much better.

1 Like

I dug into this a bit, and from what I found, you won't be able to set this via Terminal: Apple stores those shuffle values as binary blobs, for stupid reasons only Apple knows. Cynical Me would say they do it to make it impossible for users to change things programmatically.

So that leaves AppleScript, and UI scripting is horrid and I hate the syntax, so I always use an AI to help me find the right buttons. In this case, it was Claude that found the right mix of groups and splitters and scroll areas...

tell application "System Settings"
	activate
	delay 1
	reveal pane id "com.apple.Wallpaper-Settings.extension"
	delay 2
end tell

tell application "System Events"
	tell process "System Settings"
		-- Click the Shuffle popup button
		click pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		
		-- Select your desired interval (change this line to your preference)
		click menu item "Every 5 Minutes" of menu 1 of pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
	end tell
end tell

delay 1

tell application "System Settings" to quit

Just to be 100% clear: The above code was written by Claude, not me. Use at your own risk, but I've tested it here, and it seems to work.

You can put any of the available options from the pop-up in the Every 5 Minutes string, but make sure you match the text exactly. Or you could set it in a Keyboard Maestro variable, then read that variable into AppleScript and set it based on the variable.

You may also have to play around with the delay lines to make things work, depending on the speed of your system.

-rob.

1 Like

You used to be able to do it via AppleScript and System Events, something like

tell application "System Events"
	tell current desktop
		set picture rotation to 1
		set random order to true
		set pictures folder to file "path:to:images:"
		set change interval to 900 -- 15 mins in seconds
	end tell
end tell

...but I think this got broken in Tahoe. I haven't tried hard, but I get a lot of missing values when trying to view any of the above settings.

There is a "Set Wallpaper" action in Shortcuts -- you could always fire that off every n minutes with the path to the next picture you want!

You could even skip Shortcuts and do this all in KM with the Set Desktop Image action. There are a few ways you coud randomise the next wallpaper at a particular path.

This works. But how can I select which monitor it applies to?

And did you use any other tool than Claude to help you with this?

Just Claude; no clue on the displays question, but an AI can probably find that button, too.

-rob.

Here's the chat I had with Claude for the above AppleScript:

https://claude.ai/share/39d6dd32-848f-4f1c-b2a1-ae6a8baf592d

-rob.

I tried. I asked Claude to compose an AppleScript to select the monitor in the wallpaper pane of system settings for macOS Tahoe 26.2, but it was unable to do so.

Here's one that works, with a caveat:

tell application "System Settings"
	activate
	delay 1
	reveal pane id "com.apple.Wallpaper-Settings.extension"
	delay 2
end tell

tell application "System Events"
	tell process "System Settings"
		-- Click the display selector dropdown
		click pop up button 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		
		-- Type "P" to jump to PA27JCV
		keystroke "p"
		delay 0.2
		
		-- Press return to select
		key code 36 -- return
		delay 2
		
		-- Now set the shuffle time for this display
		click pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		
		click menu item "Every 15 Minutes" of menu 1 of pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 1
	end tell
end tell

tell application "System Settings" to quit

The caveat is that I was only able to make it work by doing type-selection in the menu. If I tried to access the menu by its name (PA27JCV), it didn't work. But typing 'P' and Return worked. You'll have to adjust the script for your display names, and if you have identical names, you'll probably have to use the arrow keys to navigate the menu.

Again, this was 99.5% Claude, but getting there took somewhat more back-and-forth; here's the chat:

https://claude.ai/share/34c08ed8-c162-4047-a61d-c38ca83f743a

Note that the script I posted above has an added delay after the activate that isn't in the final Claude version; without that, the panel doesn't have time to appear, and the script fails.

-rob.

1 Like
-- with everyone's help (including Claude), this works
-- Change the display names to conform to your configuration of coures.
---
tell application "System Settings"
	activate
	delay 1
	reveal pane id "com.apple.Wallpaper-Settings.extension"
	delay 2
end tell

tell application "System Events"
	tell process "System Settings"
		-- Click the Shuffle popup button
		
		click pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		
		-- Select your desired interval (change this line to your preference)
		click menu item "Every 15 Minutes" of menu 1 of pop up button "Shuffle" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		--
		
		delay 0.5
		click pop up button 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		keystroke "DELL S3225QS"
		delay 0.5
		key code 36 -- return
		
		delay 0.5
		click pop up button 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
		delay 0.5
		keystroke "SE2717H/HX"
		delay 0.5
		key code 36 -- return
		delay 0.5
		
	end tell
end tell

delay 1

tell application "System Settings" to quit
```