Script to change downloaded mac wallpaper automatically?

I want to change my mac wallpaper daily with microsoft bing images. I found this script that download the daily picture automatically, but I sill have to set the wallpaper automatically. Is it possible to write a script (either terminal or applescript) that set the downloaded picture as wallpaper automatically?


Solved! I used the Bing Wallpaper.app found here that does exactly what I needed.


You could use this script taken from here.

#!/usr/bin/env python
import os
import md5
import pprint
import sys
import subprocess
from time import strftime
from urllib import URLopener
from urllib2 import urlopen
from xml.dom.minidom import parseString

# Defines source and destination of image
rss_feed = 'http://feeds.feedburner.com/bingimages';
dst_dir = os.path.expanduser('~/Pictures/DeskFeed/')

SCRIPT = """/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
END"""


def set_desktop_background(destination):
subprocess.Popen(SCRIPT%destination, shell=True)

def parseFeed(rss):
destination = "%s%s.jpg" % (dst_dir, strftime( "%y-%m-%d"))
if os.path.exists(destination):
sys.exit(0)



try:
rss_contents = urlopen( rss )
except:
print "Failed to read rss feed %s" % rss
return
rss_src = rss_contents.read()
rss_contents.close()
dom = parseString( rss_src )
firstitem = dom.getElementsByTagName('item')[0]
link = firstitem.getElementsByTagName( 'enclosure' )[0].getAttribute('url')
URLopener().retrieve(link, destination)
set_desktop_background(destination)


def main():
parseFeed(rss_feed)

if __name__ == "__main__":
main()

The only downside is you would need to make a cron job to run it every day.