Last active
May 26, 2016 23:25
-
-
Save tigrang/5529069 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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