Home > Uncategorized > Random images for the Gnome background

Random images for the Gnome background

Choosing a random picture for my Gnome background has kept me searching for an elegant solution that could coper with the 400k+ images I have collected over the years.

Since I usually go by the dogma “download first, evaluate later” regarding wallpaper images, a fair share of my images should never have been collected in the first place. So I needed an approach that would also let me delete the current viewable image as well as randomly choose the next image to display.

Desktop Drapes is an elegant solution that have kept me going for a while, but updating the images takes too much time.

At last I decided to code my own approach. It is not yet complete, but it can serve as a wallpaper changer for the moment. The following minimal bash script will change your Gnome desktop background, provided you properly set the value of the IMG_PATH variable.

 
#!/bin/bash
IMG_PATH=/home/user/Pictures
a=( `find ${IMG_PATH} -type f | tr '\n' ' '`)
element_count=${#a[*]}
arrayPos=$RANDOM
let "arrayPos %= $element_count"
picToUse=${a[$arrayPos]}
gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$picToUse"

…to be updated

Advertisements
Categories: Uncategorized Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: