Monday 24 March 2008

random backgrounds

Excuse me for all the posts. Since I'm only just starting, I'm trying to get a lot of content out in a short time (get a good start, so to speak).

Recently I got bored with the default Ubuntu background. It's really nice looking with all the swirls and stuff, but I'd been staring at orange for long enough now. So I decided to find some cool looking new backgrounds. Sounds simple, right?

Well, not really. Sure finding a cool wallpaper is not that hard at all. In fact, it's so easy I couldn't decide which one to pick. What I really wanted was a way to get a different wallpaper each time I started my computer. Unfortunately, gnome offers no such option. So I decided to write a little script for it myself. Here's what I came up with:

path="/usr/share/backgrounds"
file=`ls $path | perl -e '@a=<>;print $a[rand(@a)]'`
gconftool-2 --type string --set /desktop/gnome/background/picture_filename "$path/$file"

It's really even simpler than I expected it would be. picking a file is a one-liner, as is changing the background. I put in a path variable so you can set the location of your backgrounds.
Now all you need is some hot backgrounds, and set this to run every time you log in (using gnome session management at system/preferences/sessions), and you have a random new background image every time you log in.

2 comments:

Anonymous said...

Yes, and putting it into cron might be fun too..

Hugo Arts said...

I thought about that as well. It's perfectly possible, but I think that a suddenly changing background may be too confusing.