How to change desktop background from OS X command line
I have 2 displays and it annoys me that I have to change the desktop background of each display individually. I always want the same wallpaper image on both screens.
So I wrote a small Ruby script to set the same desktop background image on all connected displays.
- Place the script in your path somewhere.
- Give it execution permissions:
chmod o+x [PATH TO SCRIPT]
- Make sure your default Ruby installation has the rb-appscript gem installed:
gem install rb-appscript(potentially prefix with
You should now be able to run the script. Simply give it a path to an image file - or the path to a folder, in which case the script picks a random image file from inside that:
Plays well with Desktoppr
I have my machine configured to set a random wallpaper image from my Desktoppr folder when I arrive at work. This keeps my desktop background fresh and inspiring (nevermind the fact that I rarely actually see it).