I am trying to run a python script to download an image and change the desktop background all through one script. The download the image part if fine, but I'm having trouble actually changing the wallpaper with python. I am trying to use this command but it doesn't actually work. Below is my attempt
subprocess.call(["defaults", "write", "com.apple.Desktop", "background", 'default=/Users/pathtomyname/img.jpg'])
SCRIPT = """/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
END"""
def set_desktop_background(filename):
subprocess.Popen(SCRIPT%filename, shell=True)