how to change all Desktop backgrounds

With Lion came the welcome ability to have individual background wallpapers for each Desktop. However, what Apple forgot to add was an option to easily make all the Desktops have the same background image when you want it that way.

There are a few workarounds, but probably the simplest – once it is setup – is to use this little script I wrote for some ASC members. It should take you about 5 to 10 minutes to set this up if you follow the procedure carefully.

1. Open TextEdit, and choose TextEdit > Preferences.
Change the settings from ‘Rich Text’ to ‘Plain text’ for New Documents. Close the Preference pane and chose File > New.

2. Copy everything in the box below and paste it into the TextEdit file you just opened:

#! /bin/bash
#script to change all desktop backgrounds

echo -n “Drag and drop an image file here then press ‘return’ or
press ‘control-c’ to cancel…”
read -e WLPR;

function change_wallpaper
defaults write Background “{default = {ImageFilePath=’$WLPR’; };}”; killall Dock

3. Save the file to

/Library/Desktop Pictures

with the name ‘ChangeAllDesktops’.

IMPORTANT: Make sure you remove the ‘.txt’ file extension in the name field AND uncheck the option at the bottom of the Save box that says ‘If no extension is provided, use .txt’.

Note that you will need to press the ‘authenticate’ button when prompted in order to save anything into the ‘Desktop Pictures’ folder. Type your password in the dialogue that pops up.

4. Open
Make the ‘ChangesAllDesktops’ file executable by copy/pasting this into the Terminal window:

sudo chmod a+x /Library/Desktop\ Pictures/ChangeAllDesktops

Press ‘return’ and type in your password. The password won’t echo to the screen, so type carefully.

5. Make Terminal the default app for the file
Open a Finder window. Click on your hard disk icon in the sidebar (if you can’t see it, go to Finder > Preferences > Sidebar and check Hard disks under the ‘Devices’ section). Navigate to the Library/Desktop Pictures folder and right-click on the ‘ChangeAllDesktops’ file.

Select Open with and then Other…. In the window, navigate to in /Applications/Utilities. It will be greyed out, so change “Recommended Applications” to “All Applications” in the menu at the bottom of the window. Do not check “Always Open With”. Choose ‘’ and ‘OK’.

6. Make a shortcut for Desktop Pictures
Drag the folder ‘Desktop Pictures’ to the Finder sidebar to make a convenient shortcut. Now when you want to change all Desktop backgrounds at the same time, click in ‘Desktop Pictures’ in the Finder sidebar, run the ‘ChangeAllDesktops’ file, and drag an image from the (already) open Finder window into the Terminal window that appears.

Press ‘return’ and your desktops are all changed!🙂

Related Posts
learning the Terminal — Part One
learning the Terminal — Part Two

About philastokes

Freelance Writer, Developer and Technical Communicator. Explaining the unexplainable with images, video and text. Scripting anything imaginable in Applescript, Bash, C, Objective C, Cocoa, Python and Xcode.

Posted on July 3, 2012, in Developer, Finder, Mission Control, Mountain Lion, OS X Lion, Terminal and tagged , , , , , , , , , , , . Bookmark the permalink. 3 Comments.

  1. Phil, this is really great, thanks!

  2. Good stuff. Alas, doesn’t appear to work 2nd physical monitor on my Lion system:


    • It should work if you disconnect the monitor first, run the script, then reconnect the monitor. Not ideal, I know.

      There is another property list key for second monitors, I guess, but I haven’t got round to tracking it down. You could do so by changing the background on the second monitor manually, then running a Terminal ‘Find’ session to list recently changed files in ~/Preferences.

%d bloggers like this: