Written on: 2005/02/09.

Some random Linux tips today...

Want to have a random wallpaper in GNOME every 15 minutes?

Make sure you have gconf installed, then make a new file in your home directory called .gnome_random

Put this code in it:


$dir = "~/Pictures/currentwallpapers/";

@files = `ls -t ${dir}*.gif ${dir}*.png ${dir}*.jpg`;

my $base = 1.1;

$tmp = ($base ** rand(log(2)/log($base)) - 1);

#$filename = $files[rand(@files)];

$filename = $files[int($tmp*($#files+1))];


#print $filename . "\n";

system("gconftool-2", "--type", "string", "--set",

"/desktop/gnome/background/picture_options", "stretched");

system("gconftool-2", "--type", "string", "--set",

"/desktop/gnome/background/picture_filename", $filename);

Then run crontab -e and add this line: 0,15,30,45 * * * * perl ~/.gnome_random

Then all you have to do is make a ~/Pictures/currentwallpapers directory and dump any wallpapers you want to be selected at random by the script in there and it will do its work. To change the time interval, simply edit the crontab.