MacOS – Automatically change OS X desktop background for all desktops + monitors

desktopmacosmission-control

Summary. Automation changes desktop background for all (virtual) desktops, but no all monitors. How to do it for all monitors?

Details.

This blog entry discusses how to automatically change background for all (virtual / Mission Control / etc) desktops with following 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

However, it doesn't change the desktop background on my 2nd monitor on my Lion-based system for any of my Mission-Controlled desktops. How does one apply above (or similar) to all physical monitors? (Hacks like this unattractive.)

Best Answer

I have dual monitor Mac at work so I will be able to give it a try tomorrow (day off today).

I think if you were to compare the output of:

$ defaults read com.apple.desktop

Before and after having manually changed the wallpaper via:

System Preferences > Desktop & Screen Saver > Desktop

That, should, bring up a window in the second display allowing you to select required image. Once that is setup and working, compare the output from the original command and see if it gives you any clues. I shall do the same tommorow and play around it with it. See if I can't give you a more complete answer.