How to use SVG to create easily changeable desktop backgrounds in Ubuntu.

I was wanting to leave myself a set of to do notes on my desktop the other day, so that I could see them after I woke up the next morning. I’ve done this a few times before, by editing the original image and saving out a new one.

I decided I wanted to make it look a bit less terrible by using Inkscape instead of the Gimp. For quick rectangles and text, Inkscape really is faster and looks better. As I was editing it, I wondered if it would be possible to use the SVG itself as a background image.

I opened up the Appearance settings, and browsed for the file. What do you know, it showed up. This in and of itself isn’t that exciting, until you realise that SVG can be changed really easily in a script. It’s just XML data. What can be interesting is that you can embed a link to a non SVG image to use an underlay. I didn’t have to duplicate my 600kb JPG, I was able to just embed that link, and then add text and paths on top of it.

What’s more exciting was that as soon as I saved any changes, the background image automatically refreshed itself. Something I was never able to make Windows XP do easily, without making an actual call to Windows’ DLL system. This was just edit, save, bam.

The possibilities are quite interesting. I may later put together some bash or python to do something fun like updating the BG with system internals, getting currently playing music, etc. Really you could do anything with this. All without damaging your original image or mucking around with graphics blitting code.

The only things to be aware of is that when you save in Inkscape, it defaults to an SVG format with a -lot- of extra information which makes the file more confusing than it needs to be. Just remember to save it as “Plain SVG” if you’re doing this. Also, the image link must be a full path. A relative link doesn’t work correctly, and Gnome can’t display the image. For example:
<image
xlink:href="/home/username/images/backgrounds/mypic.jpg"
x="0"
y="0"
width="1680"
height="1050"
id="image11" />

When it originally saved, it only saved as xlink:href=”mypic.jpg” If you’re doing future editing only in a script by changing the XML directly, you shouldn’t have to worry about this after you change it once.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>