Gentoo Wiki ArchivesGentoo Wiki


First of all get all the images you want into a folder, I used ~/Images, then you rename all of these images to 1,2,3,.. etc. These images must all have the same file extension too.

Then add this to the top of your ~/.xinitrc:

File: ~/.xinitrc

Then create ~/bin/ and add this to it:

File: ~/bin/
#Created By Andy Etches
feh --bg-scale /home/andy/Images/$BINUMBER.jpg

Make sure that you set HIBOUND to the number of the last file, not one higher than it!

An extension of this script follows:

File: ~/bin/
#Random image wallpaper selector
#ArrnekTornal <at>
#Script inspired by code by Andy Etches from the Gentoo Wiki at:
#    [[HOWTO_Openbox]]


ls "$IMAGE_DIR" > images.tmp

#Redirect input to come from themes.tmp and save as file descriptor 2
exec 7< images.tmp
exec <&7

#Declare an array to hold each image name in the directory IMAGE_DIR
declare -a IMAGES

#Read each image file name from the images.tmp file
while read -u 7 CUR_IMAGE
    #Assign the next name to the next position in the array

    #Increment array index position
    ((at i++))

#Close file descriptor 7
exec 7<&-

#Delete the temporary themes list
rm -f images.tmp


#Currently an array of images names exists
#Now set the desktop image to a random image from this array

#Get a random number from 0-MAX_INDEX

#Now set the corresponding image
feh --bg-scale "${IMAGE_DIR}/${IMAGES[${IMAGE_INDEX}]}"

The directory ~/wallpapers contains all the images desired to be potentially displayed. Running the script randomly selects one of these images and sets it as the desktop image.

Retrieved from ""

Last modified: Sat, 06 Sep 2008 09:28:00 +1000 Hits: 5,047

Created by, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.