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:
#!/bin/bash
# Simple Script to update the desktop wallpaper
# background for all desktop spaces in Mac OS X 10.7
#
# Usage: update_desktop_wallpaper.sh old_wallpaper_path new_wallpaper_path
#
# Andy Fore
# http://arfore.com
# Check for command line arguments
if [ -z "$1" ]; then
echo "Usage: update_desktop_wallpaper.sh old_wallpaper_path new_wallpaper_path"
exit 1;
else
# 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..."
cp com.apple.desktop.plist com.apple.desktop.plist_backup
# Convert the desktop plist from binary to xml
echo "Converting plist file to text format..."
plutil -convert xml1 com.apple.desktop.plist
# Update the desktop wallpaper file location/name
echo "Editing the file..."
sed -i "" "s/$1/${2}/g" com.apple.desktop.plist
# Convert the desktop plist back to binary format
echo "Converting plist file back to binary format..."
plutil -convert binary1 com.apple.desktop.plist
# 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."
fi
Example
$ ./update_desktop_wallpaper.sh 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.