How to change desktop wallpaper for all desktops/spaces?

I want to write a script to change all my desktops/spaces' wallpaper to one picture every 5 minutes. (In linux, I use feh script to do it.) So how to do it in MacOS Catalina(such as use shell or AppleScript)?

Two demands:

  1. The wallpapers of all spaces should change every 5 minutes.
  2. The wallpapers of all spaces must be the same at the same time.
  3. The wallpapers should change in random order.

I've already tried this in system preference, but that doesn't work. The wallpaper would not change until you switch to the space, and the pictures will change independently so they're not in sync.


To save anybody attempting it this way - it doesn't work.
If you don't switch to each space within every 5-minute time-window, they go out of sync again.
Just to save anyone else messing around to discover the same thing.
Don't bother voting this answer either way - it's just here for info.


This appears to be possible from the Screen Saver control panel, though it takes a little bit of juggling - basically you need to be able to do this before the next 5-minute marker on the clock to get them in sync, so start just after any 5-minute mark to have a better shot.

Open the Screen Saver control panel, set up your folder of choice as you would do ordinarily.
Check the box for Change picture.

enter image description here

Just as you'd expect, so far…

Then - hold the title bar of the control panel & hit your key command for the next space.
Again, select the folder & Check the box for Change picture

Rinse & repeat.
If you finish before the next 5-minute goes by on the clock, they will then stay in sync.

What you will actually see as you later switch to each space is the crossfade as it switches to the next image. I don't know if that is adjustable anywhere. Such transitions sometimes have a defaults read/write, but I don't know for this.

If you have dual monitors with linked spaces, you must do this for each of the two control panels that pop up, one on each screen. They drag independently, which makes it a bit more of a rush.