Script to generate my-wallpaper.xml for Gnome

3 min read

Deviation Actions

cbowman57's avatar
By
Published:
2.6K Views
Ok, I showed how to create a custom.xml to incorporate a wallpaper slideshow on Gnome (should also work on gnome derivatives, Unity & Cinnamon but not tested here) in my previous journal entry. fav.me/d5m03w3

Some people prefer a static background they can select from Appearances.  I found a script for that on Ubuntu forums, the name & link are noted in the script.  It is annotated with instructions.

It works great, hope you find a use for it.

-----------------------

#Script author: Freecore  ubuntuforums.org/archive/index…
#November 7th, 2012, 04:42 PM
#Actually, you don't have to add manually your 80 wallpapers. I wrote a script to do that (I have a lot of wallpapers I #wanted to add to the appearance menu too :smile:).

#This is the script:


#!/bin/bash

# Freecore

# This script creates an xml file that you can
# put on /usr/share/gnome-background-properties (if you want wallpapers entrys to ALL users, requires administrator rights)
# or in /home/userA/.local/share/gnome-background-properties (if you want it only for userA).

# Instructions
# (Realize that the script it's supposed to be runned like this: sh namescript FOLDER/OF/PICTURES/DIRECTION/).
# Don't forget the last "/".
# This script creates a file named my-wallpapers.xml.
# The file will have the xml code that Ubuntu (Gnome) identifies when it search for backgrounds.
# ATTENTION: The file generated will NOT include hidden folders NOR sub-folders pictures.
# ATTENTION: The file will include xml code for EACH file, so only put pictures in that folder.


xmlFile="my-wallpapers.xml"

echo '<?xml version="1.0" encoding="UTF-8"?>' >> "$xmlFile"
echo '' >> "$xmlFile"
echo '<wallpapers>' >> "$xmlFile"

# For each file in the folder ingresed by the user, it wll create an xml entry.
for img in "$1"*; do

# We'll declare a variable with the entire name of the image (extention included). It will be used to declare the next variable.
CompleteName="${img##*/}"

# We'll declare a variable with the name without the extention. It will be the name in the appearance menu
Name=$(echo "$CompleteName" | cut -d "." -f 1)


echo " <wallpaper>" >> "$xmlFile"
echo " <name>$Name</name>" >> "$xmlFile"
echo " <filename>$img</filename>" >> "$xmlFile"
echo " <options>zoom</options>" >> "$xmlFile"
echo " <pcolor>#000000</pcolor>" >> "$xmlFile"
echo " <scolor>#000000</scolor>" >> "$xmlFile"
echo " <shade_type>solid</shade_type>" >> "$xmlFile"
echo " </wallpaper>" >> "$xmlFile"

done

echo '</wallpapers>' >> "$xmlFile"


echo
echo
echo "The file has been created with the pictures in «$1»"
echo


#All you have to do is put it in a .sh text file and run it in a terminal with something like
#sh your-file.sh your/pictures/folder/ be aware of the last "/". And it's done!

#If you want the wallpapers to be able only in your appearance menu you can put the xml file in your local folder (./#local/share...) as I mentioned in the script.

#You can manage to convert the script to a Slideshow creator too with some little changes.

#I hope it'll help some people. :cool:
© 2012 - 2024 cbowman57
Comments0
Join the community to add your comment. Already a deviant? Log In