Change desktop background to solid color with Apple Script or Automator etc

I would like to write a simple Apple Script or Automator workflow that changes the desktop background to a solid color (ideally grey). I googled around extensively, but only found Scripts that change the background to a wallpaper and sot just a simple color. I know that I could just use a solid color wallpaper as a workaround, but in the system preferences I can also just pick a solid color, so I figured, that this must (should?) be possible via a Script at well.

One of thescripzts I found to change the wallpaper is as follows:

tell application “System Events”
tell every desktop
set picture to “path_to_wallpaper.jpg”
end tell
end tell

Does anyone here have an idea or pointer for me? Manny thanks in advance.

System Preferences just sets the wallpaper to one of the files found in

/Library/Desktop Pictures/Solid Colors

Have you got Keyboard maestro? You could use that to do it?

This should work, provided that you have automatic changing of Desktop pictures off in the Desktop settings.

set pictureTXT to "/Library/Desktop Pictures/Solid Colors/Solid Gray Pro Dark.png"
tell application "System Events"
	set picture of every desktop to pictureTXT
end tell
1 Like

Many thanks for your responses. Much appreciated. Will test the script and report back.

Works like a charm. Many thanks!

As far as I can tell this doesn’t actually change every desktop, just the active one (I have three set up in separate spaces).

That’s correct, as far as I know there is no way in AppleScript to manipulate the appearance of these Spaces. If you want to do that, you need to manipulate the configuration (plist) file directly. Not my cup of tea.