Skip to content

Instantly share code, notes, and snippets.

@wprudencio
Last active August 29, 2015 13:57
Show Gist options
  • Save wprudencio/9833648 to your computer and use it in GitHub Desktop.
Save wprudencio/9833648 to your computer and use it in GitHub Desktop.
Change wallpaper LXDE image from Bing Image Day
#!/usr/bin/env python
import urllib2
from xml.dom import minidom
import os
import time
url_bing_service = 'http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US'
url_image = ''
image_name = time.strftime("%d%m%Y")
def get_url_image_day():
content = urllib2.urlopen(url_bing_service).read()
xmlDoc = minidom.parseString(content)
url_image = xmlDoc.getElementsByTagName("url")[0].firstChild.nodeValue
return url_image
def download_image(url):
image = urllib2.urlopen(url)
output = open(image_name,'wb')
output.write(image.read())
output.close()
def set_image_background():
current_dir = os.path.dirname(os.path.abspath(__file__))
print "pcmanfm --set-wallpaper=" + current_dir +'/' + image_name
os.system("pcmanfm --set-wallpaper=" + current_dir +'/' + image_name)
if __name__ == "__main__":
url_image = get_url_image_day()
download_image("http://www.bing.com" + url_image)
set_image_background()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment