I started using openbox and I use feh to set my background...
I wanted a way so that each time I logged in it would change my background from a selection I chose
This is what I came up with...

#!/usr/bin/perl use strict; use warnings; # You will need to install feh to make this work... # You also need to create a folder called rotate in your home # folder under Pictures...also the names of the pics # need to be (1.jpg, 2.jpg, 3.jpg, etc.) # Keep in mind these images will be centered and need to be the size o +f # your resolution for best viewing. # by: pretendeavor # How many pictures you have in your rotate folder my $num_of_pics = 10; # Get a random number from your total of pictures my $pic = int(rand($num_of_pics)+1); chomp($pic); # Change your background using feh to a random pic from rotate folder print `feh --bg-center ~/Pictures/rotate/$pic.jpg`; # or --bg-tile, --bg-scale, --bg-seamless


Keep in mind that once you create this script that changes your background, to make it work you still need to call this script in your startup whichever distro you are using...most likely you will call this script using a sh script at startup...or at least that is what I do :D
Enjoy!!!

The early bird gets the worm but the second mouse gets the cheese.
pretendeavor

Replies are listed 'Best First'.
Re: Rotate Background At Startup
by jwkrahn (Abbot) on Jul 17, 2009 at 21:31 UTC
    # How many pictures you have in your rotate folder my $num_of_pics = 10;

    Or you could get the actual number of pictures:

    # How many pictures you have in your rotate folder my $num_of_pics = () = <~/Pictures/rotate/*.jpg>;

    Or just use ordinarily named files and pic one at random:

    my @all_pics = <~/Pictures/rotate/*.jpg>; print `feh --bg-center $all_pics[ rand @all_pics ]`;
    # Get a random number from your total of pictures my $pic = int(rand($num_of_pics)+1); chomp($pic);

    There is no need to chomp a number because there is no newline at the end of it.

Re: Rotate Background At Startup
by JavaFan (Canon) on Jul 17, 2009 at 23:02 UTC
    Considering that feh doesn't write to STDOUT when putting an image on the root window, why are you capturing its output, and printing it? Why not just use system?

    Too bad feh -z -bg-center ~/Pictures/rotate/*.jpg doesn't just do the right thing (-z to randomize the list, then have -bg-center display the first one).

Re: Rotate Background At Startup
by ambrus (Abbot) on Jul 19, 2009 at 22:34 UTC