deskTOPia: The hsetroot and Esetroot Background Tools

Background View

Andrea Müller

Users who work long hours on a desktop computer will appreciate something eye-catching to relieve the monotony. The hsetroot and Esetroot tools offer you more than an ordinary desktop.

Long gone, and rightfully so, are the days when Windows experts used to sell their users on wallpaper stripping as a top secret tuning tip. Modern computers have more than enough memory for a desktop background. And in contrast to Windows 95, most window managers in the Linux world can handle graphics in compressed and thus smaller formats such as PNG or JPG.

Desktop environments typically have a preferences dialog where users can select a wallpaper. More basic window managers may expect you to store background images in a specific directory, or even to point to the image in a configuration file. Command-line programs that load a background image remove these restrictions. In this month’s article, we will be looking at two applications that offer you more than just the ability to paint a picture in the root window: Esetroot [1] and hsetroot [2].

Incidentally, neither of these tools will work in KDE or Gnome. Both desktops plant another window on top of the root window.

Desktopia

Only you can decide how your desktop looks. With deskTOPia we regularly take you with us on a journey into the land of window managers and desktop environments, presenting the useful and the colorful viewers and pretty toys.

Figure 1: hsetroot with the “-tint” option can color a winter landscape blue.

Esetroot

Esetroot comes with the Eterm terminal emulator available at [1]. Although there are binary packages for most distributions, fans of Southpark, at least, may prefer to build the tool themselves. The configure script includes an Easter egg which checks for the fictive libkenny library, and outputs the most popular sentence in the whole series as a result (Figure 2). As an additional gag, you can disable the comment by specifying the configure parameter --without-sense-of-humor.

Esetroot requires the imlib2 graphics library and can handle the JPG, PNG, TIFF, BMP, XPM and GIF formats. Esetroot /path/to/graphic.jpg loads a file called graphic.jpg as your wallpaper. This is fine for full-screen images or simple patterns. If you do not specify any options, Esetroot will tile images that are smaller than your screen size. Esetroot uses the option -center to center smaller images. This option centers the image and colors the remaining background black.

A Better Fit

If you would prefer the image to fill the screen, you can specify the -scale option. The -scale option tells the program to scale your file to fill the screen. As scaling an image means loss of image data, the result will be a slightly out-of-focus wallpaper – this is particularly true of photos. Esetroot also changes the aspect of the image to reflect the screen resolution. If this distorts your background, you can try the -fit parameter, which tells Esetroot to scale the image to fill out the width or height of the screen but keep the original aspect. The part of the screen that the image does not fill is painted black. If you would prefer a different color, type the following command:

Esetroot -bgcolor "#ffffff" U

-fit graphic.jpg

bgcolor expects colors in HTML notation – the example would give you a white fill – or a name. The showrgb | less command tells you which color names your system understands.

The default tile mode is best for simple patterns. You can achieve a special effect by specifying the -mirror parameter. Esetroot will still tile the pattern file but gives you a horizontally and vertically tiled view (Figure 3).

Colors, Photos, Gradiants

hsetroot, which also uses the imlib2 library, goes one step further. The program not only changes the image size, hsetroot also has filters that you can apply to the desktop background. There are no ready-to-run binary packages for this tool, so you will need to build hsetroot from the source code. If the imlib2 and the imlib2 development packages are installed, you can follow the usual three steps, ./configure, make and su -c “make install” to build and install the hsetroot.

The following command would give you a monochrome olive green background: hsetroot -solid “#555500.” The tool expects colors in HTML notation, including the quotes. The kcolorchooser program gives you the values for your preferred color. If you would like something more than just a single-color background, you can use multiple -add options, followed by color definitions, to create a gradient. hsetroot -add “#ffb301” -add “#0000ff” -gradient 0 describes a gradient from orange to blue. The -gradient parameter is followed by the angle. The 0 in our example creates a gradient from the top downward. For a diagonal gradient from top left to lower right, specify -gradient -45 instead. To create a gradient with more than two colors, pass multiple colors to hsetroot with multiple -add parameters. To modify the gap, specify -addd. This parameter expects a color and a number that describes the gap. By default, hsetroot assumes a value of 1.

Figure 2: Fun for Southpark fans. An Easter egg is hidden in the configure script.

To display a background image, you need to tell hsetroot the display format. The program recognizes the options -center, -tile, -full, and -fill. hsetroot -fill graphic.jpg will display an image file called graphic.png as a full screen image and modify the aspect. If this distorts the image too much, you should specify the -full parameter instead. This expands the graphic to the maximum but without changing the aspect. The -tile option tiles the image, giving you a simple pattern on the desktop. Finally, the center parameter displays an image at its original size and colors the remainder of the background black. You can select a different color by specifying hsetroot -solid “#0000ff”-center graphic.jpg.

Figure 3: Esetroot with the -mirror parameter.

Image Manipulation

Besides scaling images, the tool can also apply filters to images. Simply specify the required filter in the command line following the image file name. If you fail to do so, the command will not work, as hsetroot needs to load the image first before it can apply a filter. For example, you can specify the -tint filter followed by a color to tint the background image with a color of your choice. hsetroot -full graphic.jpg -tint “#8181FF” colors the background image blue (Figure 1).

The blur filter also gives you interesting effects. Specify the -blur option, followed by a number, to enable the effect. Values between 1 and 5 give you useful results. The -sharpen option has exactly the opposite effect. Again the tool expects a value to control the sharpening effect.

The -contrast and -brightness options control these two parameters for the background image. Both options expect a numeric value. The default contrast value is 1. Lower values reduce the contrast and higher values increase it. You should go for values between -1 and 1. For example, the following command:

hsetroot -full graphic.jpg U

-brightness -0.5

will darken photos to make them look like they were shot at twilight

Three parameters, -flipv, -fliph and -flipd, mirror the image vertically, horizontally or diagonally. You can apply multiple filters in sequence: hsetroot will apply them in the order in which they are specified. When you are satisfied with the results and would like to save the changes, simply repeat the hsetroot command and append the option -write new_image.jpg at the end of the command line. hsetroot will then set the wallpaper with the options you specified and store the image in a file called new_image.jpg.

THE AUTHOR

After nearly two-years as an independent journalist, Andrea Mueller works as a new editor for Linux New Media AG.

When she is not taking care of articles or wrapping packages for the EasyLinux download area, she looks beyond Linux and is involved with other operating systems like QNX, BeOS and NetBSD.

INFO

[1] Eterm: http://www.eterm.org/

[2] hsetroot: http://www.thegraveyard.org/