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
I had this same question, except that I wanted to change the wallpaper on all attached monitors. Here's a Python script using appscript
(mentioned above; sudo easy_install appscript
) which does just that.
#!/usr/bin/python
from appscript import *
import argparse
def __main__():
parser = argparse.ArgumentParser(description='Set desktop wallpaper.')
parser.add_argument('file', type=file, help='File to use as wallpaper.')
args = parser.parse_args()
f = args.file
se = app('System Events')
desktops = se.desktops.display_name.get()
for d in desktops:
desk = se.desktops[its.display_name == d]
desk.picture.set(mactypes.File(f.name))
__main__()