Move Background Images Folder in GNOME

Move Background Images Folder in GNOMEIt took a time where I needed to relocate my wallpapers directory to a sub-directory and I had stalled it because I knew this would break the Gnome themes i had made. But after looking at how Gnome themes are saved this isn’t a really a big deal.

gnome-appearance-properties creates basic text files with that contain the theme information. In the directories ~/.themes/yourtheme are index.theme files where the information is kept. A text editor can edit the files easy enough if there aren’t many of them, but I think it’s easier to run sed. Sed is an amazing utility to replace and change text I’m discovering. I noticed a good number of tutorials around the net on sed. Programmers seem very adept at using it.

When editing these files with sed, if only the directory name is to be changed this is simple enough. Use the find command to locate all sed files (get it ;) hmm) and direct them to sed.
cd ~/.themes
find . -type f -name index.theme -exec sed -i "s/Wallpapers/Desktops/g" {} \;

Find uses the -exec variable to direct piping. If we were to pipe find to sed traditionally (find… | sed) we’d have to use the abstract xarg argument to make this doable. Here too I’ve also ended the string with “{} \;</” which covers spaces if I remember correctly.

If the folder has been moved to a separate directory (like in my instance) sed will need to be used differently to allow the forward slash character to be distinguished and replaced. Sed will need to use a different symbol (delimiter) to define breaks. Sed delimiters that can be used are ~@%,;: .
find . -type f -name index.theme -exec sed -i "s~Wallpapers~Prefabricated/Wallpapers~g" {} \;

I thought initially the the program awk could do this too but it my experience with awk is limited:

awk '$2=="Wallpapers"{$2="Prefabricated/Wallpapers"}{print}' index.theme

The Gentoo dev manual has a good tutorial on sed:

About Gen2ly

<3's linux

Posted on 2008-02-08, in Linux. Bookmark the permalink. 1 Comment.

  1. Thank you for your site :)
    I made on photoshop backgrounds for myspace and youtube and even more
    my backgrounds:
    have a great day and thank you again!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: