How would I go about programmatically changing the desktop background in Mac OS X? I\'d like to use python, but I\'m interested in any way possible. Could I hook up to Ter
If you are doing this for the current user, you can run, from a shell:
defaults write com.apple.desktop Background '{default = {ImageFilePath = "/Library/Desktop Pictures/Black & White/Lightning.jpg"; };}'
Or, as root, for another user:
/usr/bin/defaults write /Users/joeuser/Library/Preferences/com.apple.desktop Background '{default = {ImageFilePath = "/Library/Desktop Pictures/Black & White/Lightning.jpg"; };}'
chown joeuser /Users/joeuser/Library/Preferences/com.apple.desktop.plist
You will of course want to replace the image filename and user name.
The new setting will take effect when the Dock starts up -- either at login, or, when you
killall Dock
[Based on a posting elsewhere, and based on information from Matt Miller's answer.]