Skip navigation

mission control - how do I change all my wallpapers

35259 Views 69 Replies Latest reply: Dec 10, 2013 11:35 PM by SandersKY RSS
  • Rod_V Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jul 2, 2012 9:48 AM (in response to atlaz)

    First, if we are all lucky Apple fixed this in Mountain Lion, so it may make sense at this point to just wait until that comes out. But I like the approach of a script to solve this.

     

    A while back when I first got Lion and upon the suggestion of someone else (I think early in this thread), I changed all my desktop backgrounds to point to the same image that I placed in a stationary folder and I named that image "desktop.png". When I want to change the background on all my desktops, I simply rename and/or convert the new image to "desktop.png" and place it in the stationary folder overwritting the old image. Do a "Killall Dock" command in terminal and I am done.

     

    This works well for me but I took that a bit further since I know my way around PhotoShop and FireWorks and created one large image in that folder with the same name, "desktop.png" only with multiple layers (each layer being one of my favorite backgrounds). I then just turned on a single layer of whichever image I want for my desktop and save that. Again doing the "Killall Desktop" to apply the changes. This works better, but there is a definite limit to how many layers you can have as desktop backgrounds before PS or FW starts to crash.

     

    So I was thinking that it would be nice if there was a script that - each time I moved a new image into the stationary folder - renamed the image in the stationary folder automatically to desktop.png (or whatever all your desktops are pointing to) and then ran the "Killall Dock" command. Then it would simply be a matter of dragging the desired background image into the stationary folder and running the script.

  • softwater Level 5 Level 5 (5,370 points)

    Here's the script:

     

    #! /bin/bash

    #script to change all desktop backgrounds

     

    echo -n "Drag and drop an image file here then press 'return'...:"

    read -e WLPR;

     

    function change_wallpaper

    {

    defaults write com.apple.desktop Background "{default = {ImageFilePath='$WLPR'; };}"; killall Dock

    }

    change_wallpaper

     

    This is what you do with it:

     

    1. Copy the code above into a plain text editor. If you use TextEdit make sure it's not in .rtf format. My favourite free editor is Tincta.

     

    2. Save the file as 'ChangeAllDesktops' in your ~/Desktop folder (be sure to remove the .txt ending).

     

    3. In Terminal make the file executable by typing (or copy/paste):

     

         chmod a+x ~/Desktop/ChangeAllDesktops

     

    4. In Finder right-click the file and select "Open with" and then "Other...". Navigate to Terminal.app 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 Terminal.app.

     

    After clicking OK you should be able to execute it whenever you want by simply double-clicking it on the Desktop (of course you can move it to somewhere else, if you want).

     

    When it runs, Terminal will open and ask you to drag an image file into the Terminal window. After doing so, press 'return'.

     

    Desktops changed!

  • computerfox Level 1 Level 1 (0 points)

    Okay since the code is already out there let me just mention that, that's pretty much what my app does.

  • softwater Level 5 Level 5 (5,370 points)

    Really? The script above makes a 2kb file. How come yours is 100MB?

  • Rod_V Level 1 Level 1 (0 points)

    Good Job - I love it and it works perfectly. Small and clean. One thing though, I have an external monitor attached to my Mac Book Pro. It changes the desktops on the primary monitor but not on the secondary (which is my Mac Book Pro). Any way to get it to change those as well?

  • computerfox Level 1 Level 1 (0 points)

    Because mine is a full graphical Cocoa application.  I forgot to respond to that last comment...

     

    Oh and that's just the size I normally use for disk images.  The actual app is probably the same size as yours actually.  It's just the size of the .dmg, not the actual app.

  • computerfox Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jul 2, 2012 12:17 PM (in response to Rod_V)

    That's actually a different situation, I believe.  Even in Snow Leopard you had to change external monitors sepeartely.  I could probably figure it out, but sometimes you do want externals to be different, especially if one of them is for presentations or something.

     

    And I also saw a comment about Mountain Lion.  As much as I tested it, they fixed A LOT of the bugs, but overall it's almost exactly like Lion, that's why I think they should release it as a patch or at least release the bug fixes for what's in Lion as an update.

  • Rod_V Level 1 Level 1 (0 points)

    Thanks for the reply - But they are aparently different preferences. The way I described above in my earlier thread change all on both my Cinema display and my MBP. It didn't effect my display out to a projector (which I do all the time). That's a completely different desktop image that I can also change if I wanted to. I usually keep that one just black for when I am doing presentations.

     

    Also a word of advice, if you do figure it out, just make it a simple script. No one wants a large program or something they have to worry about. We can very simply see a script and what it is doing and that make us feel safer.

  • computerfox Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jul 2, 2012 12:24 PM (in response to Rod_V)

    I actually see your point Rod.  I now realize too that by making a 100MB disk image for an app that's probably only 3KB is also a HUGE waste of space.  I'm going to stop doing that in the future.

  • vanRijn Level 1 Level 1 (0 points)

    Awesome job on the script, softwater! Very nice job on the thorough instructions too. =:)

  • vanRijn Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jul 2, 2012 1:08 PM (in response to Rod_V)

    Hey Rod_V, if you look at the script that I posted (https://discussions.apple.com/message/18804273#18804273), and the web page I reference, you'll see some more sophisticated python code that changes all desktops on all monitors. Or at least that's what it says it does. And if it doesn't work perfectly, it seems pretty simple and easy to debug and fix.

  • Rod_V Level 1 Level 1 (0 points)

    Thanks vanRijn, I'll check both of those out.

  • softwater Level 5 Level 5 (5,370 points)

    Thanks, but the drag and drop thing is a bit annoying.

     

    To make it a bit less inconvenient, move the file to

     

    /Library/Desktop Pictures

     

    (note: you will need to authenticate when prompted in order to save into the 'Desktop Pictures' folder),

     

    then drag the folder 'Desktop Pictures' to the Finder sidebar to make a convenient shortcut.

     

    Now when you want to change all Desktop images, click in 'Desktop Pictures' in the Finder sidebar, click this file, and drag image from the (already) open Finder window. If you save all your Wallpapers in this location then there'll all be in one spot and the window open when you run the program

     

    I've changed the script slightly from above to include the escape sequence, as many people aren't familiar with Terminal, so what if...

     

    1. I ran the script but now I don't want to use it?

    If you change your mind or select the wrong file, you can use 'control-c' to kill the script without making the change. If you don't enter anything but press 'return', you'll change all the wallpapers back to the default galaxy pic, so the 'control-c' trick is worth knowing.

     

    2. I dropped the wrong file onto Terminal?

    If you drop the wrong file and want to chose another one, just keeping pressing the 'delete' key till its removed from the command line, then drop the correct file. Alternatively, you can still use 'control-c' to kill the script at any time before you hit 'return'.

     

    Here's the slightly changed script:

     

    #! /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

     

     

    ###################

    #after testing, save this program in /Library/Desktop Pictures

    #drag the folder 'Desktop Pictures' to the Finder sidebar

    #now when you want to change all Desktop images, click in 'Desktop Pictures'

    #in Finder, click this file, and drag image from the open Finder window

    #note: you will need to authenticate when prompted

    #in order to save into the 'Desktop Pictures' folder

    ###################

  • softwater Level 5 Level 5 (5,370 points)
    Currently Being Moderated
    Jul 3, 2012 2:13 AM (in response to Rod_V)

    Rod_V wrote:

     

    It changes the desktops on the primary monitor but not on the secondary (which is my Mac Book Pro). Any way to get it to change those as well?

     

    Ah, funnily enough I was using an external today at work and noticed this. I agree its annoying.

     

    Hmm, I'll have to hunt around in the default properties list and see if I can find the command. Shouldn't be too difficult to build into the script once I have that. If anyone knows it, please post here.

  • vanRijn Level 1 Level 1 (0 points)

    Grr. It seems that with Mountain Lion, the python approach I mentioned from http://stackoverflow.com/questions/431205/how-can-i-programatically-change-the-b ackground-in-mac-os-x doesn't work right anymore. Anyone have a solution (shell scripting is fine by me!) that works with Mountain Lion and with all spaces and with external monitors too? =:)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (3)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.