Setting the CDE Backdrop - shell script

CDE doesn't make it easy to set the background image of the workspaces dynamically. If you do it the CDE way, you have to convert your image to a pixmap, which will turn large images into ridiculously large images. There's also no easy way to set the backdrop from within a script, or at least there wasn't until now. You can set the real X root using any X11 tool that does that, and then tell CDE to use NoBackdrop, but then all of the screens will have the same background. Also note that Solaris' X11 server doesn't work correctly for large images on the background with Xinerama mode -- the first screen gets re-tiled onto the second (some versions of XFree86 also have this bug but the latest versions should have it fixed). Since the whole reason I did this was to look at jumbo images across both of my monitors, I found another way.

cde-backdrop is a shell script (/bin/sh) that can be used on the command line or called from other scripts, which will find the CDE backdrop window which you select by name, and apply an image (in a variety of formats) to that background.


    cde-backdrop [ workspace | -select ] imagefile
    cde-backdrop -list
    cde-backdrop [ workspace | -select ] -id
"workspace" can be the workspace's given name (shown on the front panel button of CDE, and changeable by the user), or it can be the internal name of the workspace which is "ws" followed by the number of the workspace starting at zero (e.g. ws2 is the third workspace).

If "-select" is given as the workspace, you will be prompted to click on the window where you want to set the background. In theory this could load backgrounds onto all kinds of windows, but it won't do anything with most application windows.

If no workspace is given the current workspace is used.

The imagefile is just the filename of an image. Images are painted onto CDE windows using the xloadimage program (a standard program in the X11 distribution). The script attempts to convert some file types that xloadimage does not support into types that it does. If the script can't figure out what the file is from the extension, it just passes it to xloadimage anyway and hopes that xloadimage knows what to do with it. As a special case, the filename "-" tells the script to read the image from standard input.

A filename of "-id" tells the program not to paint the background. Instead, it simply reports the window id of the CDE backdrop that you requested. This might be useful for writing other scripts, or if you have something besides "xloadimage" that you want to use.

If "-list" is given as the imagefile, then a list of workspaces is printed and the program exits. This might be useful for writing a script which periodically changes all available backdrops.


No fancy tar files, and no documentation besides what's here, this link downloads the script file directly, so you might want to shift-click (or do whatever your browser requires) to convince it to download to a file.

Before you download, consider the program requirements. You have to be running CDE (duh). You also need xloadimage, which is available at And you need xprop and possibly xwininfo, but these are both standard X11 programs. If you will be using JPEG images, you will need djpeg, and if you will be using TIFF images, you will need tifftopnm. (NOTE: the latest version of xloadimage can handle both JPEG and TIFF images, however many people are running older versions. If you do have the latest xloadimage, the script can be easily modified to not require tifftopnm and djpeg.)

Download cde-backdrop version 1.0


  1. Read the requirements above, and download.
  2. Edit the line of the file that reads "PATH=" to include the paths to the required programs (only if they aren't already in your path). For example, in my case I have added /soft/netpbm/bin because that's where my tifftopnm executable lives. You'll at least want to remove my customization because it is highly unlikely that you'll have anything there.
  3. Copy the edited file to a place in your path, usually /usr/local/bin or $HOME/bin.
  4. Make sure the file is executable (e.g."chmod +x filename").
  5. Enjoy.


  • This is not the CDE way to set the backdrop. CDE won't know that the backdrop has been changed, and it won't save the backdrop for next time.
  • I haven't tested it with CDE when using an 8-bit default visual. It should work, but I haven't tested it.
  • Option processing is really stupid. You can't say "cde-backdrop -id -select", because it doesn't expect them in that order.
  • It would be good to support xloadimage options for zooming, rotating, cropping, etc.
  • This isn't really a problem with this script, but I recommend you have good bit of memory before you paste up lots of full screen images on your backdrops - if your machine memory gets tight, changing desktops will be    v e r y      s l o w w w w w w w .

    Please let me know if you have additional information or comments.

    Tom Fine's Home Send Me Email