Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Set the Desktop Background for all of your open Spaces in Mountain Lion
read -e IMAGE;
defaults write Background "{default = {ImageFilePath='$IMAGE'; };}"
killall Dock


  1. Open Automator and create a new Service
  2. Set "Service receives selected" to "image files"
  3. Add a "Run Shell Script" action to the workflow, remove the default script contents, and paste the script into it
  4. Save as "Set as Wallpaper"

The service should then be available to you when right-clicking image files. Right-clicking an image file (png, jpg, etc) in the Finder and choosing "Set as Wallpaper" will set that image as the Desktop Background image for all open Spaces. No need to quit apps or delete Spaces!

You can use an app like Services Manager to organize your Finder context menus.

Copy link

nodomain commented Jul 27, 2017

In newer OSX versions you need to use this command since Apple moved the settings to a SQLite DB

read -e IMAGE;
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$IMAGE'" && killall Dock
killall Dock

Copy link

eliranmal commented Jul 30, 2017

thanx @nodomain!

Copy link

TheFullResolution commented Aug 4, 2017

@nodomain you have one killall Dock too much... specifically the last one

Copy link

frantzmiccoli commented Dec 14, 2017

If you are starting from a blank installation you need to change the background picture at least once per space (otherwise the entity don't exist in the SQLite database structure).

Copy link

stephantual commented Jan 29, 2018

Very useful - doesn't take care of the alignment settings but in itself a massive improvemnt over the dreadful process of having to go space by space :) Thank you! 👍

Copy link

TheFullResolution commented Oct 7, 2018

Right now on Mojave, script corrupts desktoppicture.db - for now only fix is to delete this file from ~/Library/Application Support/Dock/

Copy link

Kondenko commented Oct 13, 2018

@TheFullResolution thanks for the warning! Have you found a script that works on Mojave?

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