Skip to content

Instantly share code, notes, and snippets.

@tigrang
Last active May 26, 2016 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tigrang/5529069 to your computer and use it in GitHub Desktop.
Save tigrang/5529069 to your computer and use it in GitHub Desktop.
import os
import xml.etree.cElementTree as ET
wallpapers = ET.Element("wallpapers")
for root, dirs, files in os.walk(os.path.expanduser("~/Pictures")):
for file in files:
if (file.lower().endswith(('.png', '.jpg', '.jpeg'))):
wallpaper = ET.SubElement(wallpapers, "wallpaper")
wallpaper.set("deleted", "false")
name = ET.SubElement(wallpaper, "name")
name.text = file
filename = ET.SubElement(wallpaper, "filename")
filename.text = os.path.join(root, file)
options = ET.SubElement(wallpaper, "options")
options.text = "zoom"
tree = ET.ElementTree(wallpapers)
tree.write(os.path.expanduser("~/.local/share/gnome-background-properties/gnome-backgrounds.xml"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment