setbg -- Set background wallpaper of X11 display to random picture from file list



setbg [-h] [-v height] [-w width] [-n t1] [-x t2] file_list



Randomly selects one of the pictures in the file list and displays it as the background wallpaper to the root window in an X11 display for a time between t1 and t2 minutes, after which the picture is changed.

If the height of the picture is greater than height, or the width of the picture is greater than width, then the picture will be centered on the background. Otherwise, the picture will be tiled.



-h Displays a brief help file

-v Minimum height of a picture to be centered rather than tiled

-w Minimum width of a picture to be centered rather than tiled

-n Minimum minutes a given picture is on the screen

-x Maximum minutes a given picture is on the screen



The default values of width and height are set so that the picture is automatically tiled.

If neither t1 nor t2 is set the picture never changes.

If only one of the variables t1 or t2 is specified, or if t1 > t2, then the program sets t1 = t2, i.e., there is no randomness in the time a given picture is on the screen.

If either t1 or t2 is negative it is reset to its absolute value.



As written, this requires the ImageMagick package (, or alt least the display program from that package. However, any program which can display an image in the root window (e.g. xv) can be used here. Just replace the call to display with a call to an alternative program.

The width and height settings require the use of the identify command from the ImageMagick package.

setbg uses the Getopt::Long module to read the command line options



setbg -w 800 -n 60 -x 120 $HOME/pictures/*.jpg

Randomly selects pictures from all JPG files in the directory $HOME/pictures, switching every 60 to 120 minutes. If the picture has a width greater than 800 pixels, it is displayed centered on the root screen, otherwise it is tiled.



    Copyright (©) 2005  Michael Mehl



This file is released under the GNU General Public License (GPL). A copy of the license should be available along with the source code for this program, if not, see the comments at the end of the source code, or see