Changing wallpaper on all spaces in Mac OS X 10.7

I have been updating my wallpaper to a new monthly desktop wallpaper from the Smashing Magazine site for several months.

With earlier versions of Mac OS X it was easy to update all spaces at once because the default change action affected all the spaces. With the advent of Mac OS X 10.7 (aka Lion) each space is capable of having a unique wallpaper. While this is a neat feature, there is no option to apply the change to all the spaces. One workaround is to manually change each space.  Another workaround is remove all your spaces, make the change then add the spaces back.

Neither of these options is suitable to me. The first option is fairly cumbersome, and the second will undo my application-to-space bindings. To solve this problem I have written a script than handles it.

Here’s the script:


# Simple Script to update the desktop wallpaper
# background for all desktop spaces in Mac OS X 10.7
# Usage: old_wallpaper_path new_wallpaper_path
# Andy Fore

# Check for command line arguments
if [ -z "$1" ]; then
    echo "Usage: old_wallpaper_path new_wallpaper_path"
    exit 1;
    # Change location to the active user preferences directory
    cd ~/Library/Preferences

    # Backup the original plist file
    echo "Making a backup of the original plist file..."

    # Convert the desktop plist from binary to xml
    echo "Converting plist file to text format..."
    plutil -convert xml1

    # Update the desktop wallpaper file location/name
    echo "Editing the file..."
    sed -i "" "s/$1/${2}/g"

    # Convert the desktop plist back to binary format
    echo "Converting plist file back to binary format..."
    plutil -convert binary1

    # Killing Dock process
    echo "Sending the kill signal to the Dock process to force reload of plist"
    killall -HUP Dock

    # Display completion message
    echo "Operation now complete."


$ ./ June2012_Calendar.jpg July2012_Calendar.jpg

Note that I only used a filename in the example. This is because all of my calendar wallpapers are saved in the same directory path, making the unique part just the filename itself.

  • Mohan

    I tried like $ sh ~/image1.jpg ~/image2.jpg but nothing changed on my desktops :)