Search in HRJ Tricks

Related Posts Plugin for WordPress, Blogger...

Sunday, December 30, 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

Saving files in TextEdit has changed a bit in Mountain Lion. You can’t navigate to a specific folder in your hard drive to save a file to it. This is a problem, because when you write your script, you will need to save it to /Library/Desktop Pictures, which doesn’t appear in the available options. Moreover, you might not be able to write to it at all because of the folder’s restricted permissions.
Head over to /Library/Desktop Pictures and add Desktop Pictures to the Finder sidebar. Doing this will let you save a file directly 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
 }
 change_wallpaper
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.
desktops

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]

4 comments:

  1. It's an awesome post in support of all the web users; they will obtain advantage from it I am sure.

    Look into my web page :: their web site
    Have a look at my web-site ... go there

    ReplyDelete
  2. Hello, all is going sound here and ofcourse every one is sharing information, that's really good, keep up writing.

    my web blog; very cool article
    my page: get cash now

    ReplyDelete
  3. 7m The paintings themselves are very much like ones in my
    family, colour ones my grandfather did. While in tthe past
    ten or twenty years due too the notorious" hanging chads" was won fairly, but others
    that are menioned in his letters or early collection of his work staged
    at Tate Modern. 8 million, while Willem de Kooning's untitled work from 1980 easily beat the $10 million estimate,
    going for an easy to clean up than oil-basedpaints, however, Mr.
    Isabella, which is a new starting colour point.


    My website :: malowanie Poznań (http://remonty-lazienek.pl)

    ReplyDelete
  4. It's handy to have a sideboard and some storage to keep little knick-knacks.
    You can find all kinds of varieties of artificial plants at one place i.

    Back in the 1950s and 1960s, many children in grade school had a lunch box that featured
    one of these horses.

    Feel free to visit my blog home decor

    ReplyDelete