17 Dec 2012

How To Set One Wallpaper For All OS X Desktop Spaces At Once

First introduced in OS X Lion, Desktop Spaces provide an excellent platform for window management. Since then, the feature has become one of the most popular additions in OS X, though it is considerably limited in some areas. It’s the closest you get to a virtual desktop available system wide, so you won’t see too many complaints. At present, each desktop space operates somewhat independent of the other. You get the same desktop icons no matter which space you’re on, but you can keep windows and apps separate.
You can also, by default, make the wallpaper for each space different. This might seem useful, but a fair number of users would prefer the same background across all desktops, and that isn’t possible in two clicks or less in OS X. It lacks any way to change the background for all desktop spaces at once, which is why you might need an app or script for that. We haven’t yet found an app that does so, but a simple script does the trick fairly well. The process of creating the script is simple, but a little lengthy, so we’ll break it down as best as we can to make it easier to follow.

Apps You Will Work With

You will be working with:
  • TextEdit
  • Terminal
You will also need to access the Library folder at the root of your hard drive and create a shortcut for the script you make on Finder sidebar.

Folder Permissions

Head over to /Library/Desktop Pictures and add Desktop Pictures to the Finder sidebar. Doing this will let you save a file more easily to this folder from TextEdit’s Save As dialog. Next, right-click this folder, go to Get Info, and make sure you have permissions set to Read & write.

Writing The Script In TextEdit

Open TextEdit’s preferences and make two changes: in the ‘New Document’ tab, select the ‘Plain Text’ option under ‘Format’, and in the ‘Open and Save’ tab, uncheck the option labeled ‘Add “.txt” extension to plain text files’.
textedit permissions textedit
Open a new TextEdit document and paste the following script in it:
#! /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 com.apple.desktop Background “{default = {ImageFilePath=’$WLPR’; };}”; killall Dock
Save this file to the Desktop Pictures folder you added to the Finder sidebar. If it tells you that you don’t have permission to save to this folder, revisit the folder’s options to recheck if permissions are set to Read & write. Save this file with the name ChangeAllDesktops; it should NOT have a TXT extension.

Making Your Script Executable

It’s now time to tell your OS that this file you just made is going to be making changes to the desktop. Open a Terminal window, run the following command and enter your password when prompted to do so.
sudo chmod a+x /Library/Desktop\ Pictures/ChangeAllDesktops
executable script
Head over to your file now and open it with Terminal. Note that you shouldn’t set OS X to always open these types of files with Terminal. Just open it once, so that it knows which app to default to when you open the file.

Changing Desktop Backgrounds

The ChangeAllDesktops file will open in the Terminal asking you to drag & drop the image you want to set as the desktop background.
change desktop
Drag an image from the Finder onto the Terminal window and hit Enter. The background across all desktops will change to the selected image.
It is interesting to note that if you don’t drag & drop an image to the Terminal when you run the file and simply hit enter, the background for all desktops will be reset to the default galaxy wallpaper.

Have I Broken Anything?

After having to alter permissions of the Library folder and running a few Terminal commands, you might wonder if what you’ve done is permanent, or if it is reversible. Advanced users will know right away that this is not a permanent change, but to set your mind at ease, here’s why.
You’ve only run a script that changes the desktop background. It runs once and makes whatever change it is meant to make without leaving any permanent traces. In this case, it’s changed the desktop backgrounds, which is easily reversible from your System Preferences. The script file, on it’s own, does absolutely nothing unless you add an image to it or hit enter, and after you do run it, you will still be able to change the background of each desktop space individually.

Why Isn’t It Working?

This will work on both Lion and Mountain Lion with no glitches whatsoever. Should you face any problems, make sure you didn’t reset the folder permissions of the Desktop Pictures directory after saving the file to it. Additionally, make sure you saved the script file directly to the Desktop Pictures folder and didn’t copy the file to it. When we copied the file to the folder, the script wouldn’t run. Other than this, there isn’t much that could go wrong with this simple procedure. It won’t work for multiple displays, though. You can disconnect the second or third display, change the backgrounds and then reconnect them to ensure the same background on all desktops, which we admit is a tad inconvenient.
[via Phil Stokes]
How To Set One Wallpaper For All OS X Desktop Spaces At Once Reviewed by Unknown on 17 Dec 2012 Rating: 4.5

No comments:

Post a Comment

Disqus for android phone


Related Posts Plugin for WordPress, Blogger...