Basic FVWM Configuration

John M. Fisk

Issue #28, August 1996

If you've recently set up fvwm and are using the default system.fvwmrc, you'll find that clicking the left mouse button anywhere in the root window brings up a pop-up menu. Not all of those entries will be valid for your system. Here's how to change them.

If you've recently set up fvwm and are using the default system.fvwmrc, you'll find that clicking the left mouse button anywhere in the root window brings up a pop-up menu. What you may also quickly discover, to your dismay, is that many of these program items don't do anything, either because the program doesn't exist or is incorrectly set up.

Because of this, you'll probably want to remove these menu entries. Also, sooner or later, you'll install programs that you'd like to add to the pop-up menu. Or you may decide that you want to reorganize the menu into categories, such as Editors, Graphics, Viewers, Network Apps, and so forth. Whatever the reason, configuring the pop-up menus is easy and a huge amount of fun. So let's look at how it's done.

Suppose you do a lot of text-editing or programming and have several editors you enjoy using. You now want to organize the pop-up menu by program category and want to put all your favorite editors under one pop-up sub-menu, called Editors.

For the sake of simplicity, we'll leave out a discussion of using command line options for things such as geometry, foreground and background colors, fonts, and so forth. We'll use fairly simple examples and assume that you can go back later and customize the command line options.

Be sure you've made a backup copy of your current working version of .fvwmrc. After that, load up your favorite editor and open the file used to define the pop-up menus, .fvwmrc. This will include entries such as:

Popup "Applications"
  Title "Applications"
  Exec  "Wingz"     exec Wingz &
  Exec  "Xmgr Plot" exec xmgr -g 780x730+362+3 &
  Exec  "Ghostview" exec ghostview &
  Exec  "Seyon"     exec seyon -modem /dev/modem &
  Exec  "SciLab"    exec scilab &
  Exec  "X3270"     exec x3270 &
  Exec  "Xfilemanager" exec xfilemanager &
  Exec  "Xfm"       exec xfm &
  Exec  "Xgrab"     exec xgrab &
  Exec  "Xxgdb"     exec xxgdb &
EndPopup

Your .fvwmrc will probably look a bit different than this, so find the section of the file that defines Popup "name" ... EndPopup stanzas. Without fully understanding how things work, you could probably use an entry such as the above as a template and modify the entries to include the programs you want. What you'll discover, however, is that this isn't hard to understand.

An important point to keep in mind is that you must define sub-menus first, before you define the main menu. The reason for this is actually quite simple: when fvwm starts it reads the .fvwmrc configuration file from beginning to end. If you define the main menu first, it encounters references to menu items (your sub-menus) that haven't been defined yet, and so it is unable to correctly set up the menus. Also, sub-menus can be nested to any depth. Once you have a list of editors to add to a sub-menu, and you've worked out the command line options you intend to use, you're ready to start.

The basic entry for a menu takes the form:

Popup "name"
  Title  "title"
  Exec  "program"  exec command &
  Exec  "program"  exec command &
  Exec  "program"  exec command &
  Nop   ""
  Exec  "program"  exec command &
  Exec  "program"  exec command &
EndPopup

Let's briefly look at each part of the entry. The entry begins with the word Popup and a "name" which is used to refer to this menu itself (we'll see how this is used in a minute when we talk about adding a sub-menu to the main menu). The next line, beginning with the word Title, specifies the title that appears at the top of the menu. Notice that the title is enclosed in double quotes. Next are a series of familiar Exec stanzas, each of which is used to launch a program. This time, however, the word following Exec and enclosed in double quotes is the name that will appear on the menu. A stanza for the xedit editor might look something like:

  Exec "XEdit" exec xedit -font 9x15 -g +5+20 &

The menu would then include an entry with the name XEdit: clicking on this would launch the xedit program with the font and geometry options that are specified on the command line. Don't forget the ampersand (&) at the end of the entry.

You'll also notice a line which begins with the word Nop, which, as its name suggests (to some people, anyway), performs “no operation”. It does, however, allow you to create separator lines between menu items. Nop followed by a pair of double quotes with no spaces between them ("") creates a separator line. This is very useful for visually separating a list of items in the menu. However, if Nop is followed by double quotes with a space between them (" "), an empty entry is created between menu items instead of a line. Try both and see the difference.

Finally, the reserved word EndPopup is used to indicate that the menu has been defined. Pretty simple, eh? Once you understand how menus are defined, you can easily use an existing menu definition as a “template” for creating one of your own.

One more quick point to mention: it is possible to launch fvwm modules from a pop-up menu. As with the InitFunction entries mentioned last month, these are really quite simple and use the same form:

Module  "name"  module

For example, to start up the FvwmPager, you would add something like the following:

Module  "Pager"  FvwmPager

Notice two things: the menu item name for the module can be anything you want—it doesn't have to be the same as the module name. Second, you do not put an ampersand (&) at the end of the command line.

Putting It All Together

So, now that we've touched on the basics, let's put all of this together and create a sub-menu for our editors. Supposing that we wanted the menu title to be Editors and the Popup itself to be referred to as editors, then we could create something similar to the example given below:

Popup "editors"
  Title "Editors"
  Exec  "XE&dit"      exec xedit &
  Exec  "X&Coral"     exec xcoral &
  Exec  "GNU &Emacs"  exec emacs -g 84x47 &
  Exec  "&XEmacs"     exec xemacs &
  Exec  "XW&PE"       exec xwpe -font 9x15 &
  Exec  "X&WE"        exec xwe -font 9x15 &
  Exec  "&aXe"        exec axe -noserver &
  Exec  "&NEdit"      exec nedit &
  Exec  "E&Z Editor"  exec ez &
EndPopup

So far so good, eh. What's that? What are those ampersands doing in the menu item name entry? Fvwm allows you to define keyboard shortcuts to use with menus. Placing an ampersand in an item name causes the letter following the ampersand to be underlined. Then, when the menu is displayed, hitting that underlined letter causes the program item to be executed.

In the menu defined above, the letter “d” in XEdit would be underlined and would appear as “XEdit”. Once the menu has been displayed, hitting a “d” launches xedit. It goes without saying that you should avoid defining the same hot-key for two items in the name menu.

Ok, we're almost done. Now that we've created a sub-menu, let's add this to the main menu. An entry for a sub-menu takes the form:

  Popup  "Editors"  editors

Pretty easy, huh? The syntax should start to look pretty familiar to you by now. The line begins with the word “Popup” indicating the the item is a sub-menu of some kind. Following this, and enclosed in double quotes, is the item name that will appear on the menu. Finally, the last argument is the name of the pop-up menu itself. Remember that we decided to call the pop-up editors? This is the name by which the sub-menu is called. Be careful not to mix up the name of the pop-up menu with the title (e.g., “Editors”) that the menu uses.

Well, congratulations! You should now be well on your way to customizing and configuring. There are many more things that can be included on a pop-up menu although programs, modules, and sub-menus are probably the the ones you'll use the most. Once you get comfortable creating menu entries, skim over the fvwm manual page and take a look at the sample fvwmrc file that comes with the fvwm distribution to get ideas about what else can be done.

As a final word of exhortation let me suggest that “moderation in all things” is probably sage advice. It is unnecessary and unwise to create an entry for every program on your system. Add programs that you frequently use and make them accessible. Nesting sub-menus beyond one or two deep is likely to make getting at them more of a chore than it is worth. Also, more than 15 to 20 items on a single menu will probably make it a bit unwieldy. [Actually, experts in human-computer interaction suggest that the human mind is less efficient when dealing with more than 7 items (or groups of items) together. —ED] Use your discretion and divide things up if you need to. Most of all, though, have fun!

Color Customization

By now you should start feeling pretty good about fvwm. You've learned the basics of creating a start up desktop and you've re-organized and customized your pop-up menus. This is pretty good, eh? One of the next items on the customization to-do list is invariably colors. Like most everything associated with fvwm, colors are extensively customizable. Doing this, however, can be just a bit tricky, not because it's all that difficult, but because several entries govern how colors are applied to various programs and windows. Once you track all of these down, and understand a few simple concepts about how colors are defined, the rest is play. At the outset, however, it is helpful to know something about how fvwm views windows (no, not that Windows...).

Fvwm recognizes and makes a distinction between a couple of different “types” of windows. These include the “selected” window—that which has the input focus—“unselected” windows—those which do not have the input focus—and “sticky” windows—those which “stick to the glass” as it were. It is possible to customize the color scheme for each type of window. Parenthetically, let me also point out that it is easy to change the color of the root window or to use a bitmap or pixmap image in the root window as the “wallpaper”. In Part 1 of this series we saw that the xsetroot program allows you to change the color of the root window (see the sample .xinitrc file). There are much more fun and entertaining ways to change the root window, but I'll leave that up to you for the moment (hint: man xpmroot and man xv should give you some ideas...).

So, back to customizing the various windows. Fvwm allows you to individually customize selected, unselected, and sticky windows as well as menus and the pager. These are set using the following reserved words:

StdForeColor
StdBackColor
StickyForeColor
StickyBackColor
HiForeColor
HiBackColor
MenuForeColor
MenuBackColor
MenuStippleColor
PagerForeColor
PagerBackColor

ForeColor stands for the foreground color and BackColor stands for the background color. This is quite typical of how colors are designated under X—using a foreground/background combination to set the color scheme. A brief explanation of each of these is as follows:

StdForeColor foreground color for menus and non-selected window titles

StdBackColor background color for menus and non-selected window frames

StickyForeColor foreground color for non-selected sticky window titles

StickyBackColor background color for non-selected sticky window frames

HiForeColor foreground color for selected window's title

HiBackColor background color for selected window frame

MenuForeColor foreground color for menus

MenuBackColor background color for menus

MenuStippleColor color for shaded-out entries in a menu

PagerForeColor foreground color for pager

PagerBackColor background color for pager

Setting up the color scheme you want is a matter of adding an entry such as:

StdForeColor    black
StdBackColor    wheat

This would set the foreground (text) color to black and the background color to wheat.

Armed with this new knowledge, you head off to customize colors, and find an entry that looks like:

StdBackColor    #8a4510

If you're having a little trouble closing your eyes and visualizing just what the color #8a4510 might look like... ...keep reading.

Xcolorsel to the Rescue!

The color designated by the entry #8a4510 (which, for the curious, happens to be SaddleBrown) is in hexadecimal notation. As of X11 Release 5, there are several means for specifying color: two commonly used formats are RGB color names (such as SaddleBrown) and RGB hexadecimal values (such as #8a4510). The acronym RGB stands for “Red, Green, Blue” and has to do with how colors are generated.

Recall from your school days that all colors can be produced by a combination of primary colors—cyan, magenta, and yellow. Technically speaking, these are the “subtractive” primary colors of paint; when you put them all together, they subtract all the light and make “black” (it really turns out brown). It is also possible to create colors using a combination of red, green, and blue “additive” primary colors of light—when you put them all together, they add up to make white. Hence, the RGB designation indicates the amount each of red, green, and blue light which make up a color. To see what colors are available to you under X, you can view the file /usr/lib/X11/rgb.txt. This file contains a listing of all of the named colors on your system. This might contain a listing such as:

...
139  69  19             saddle brown
139  69  19             SaddleBrown
160  82  45             sienna
205 133  63             peru
222 184 135             burlywood
245 245 220             beige
245 222 179             wheat
...

Each line contains the color name and three columns of numbers which represent the relative contribution of red, green, and blue values based on a scale from 0-255—the range of numbers that can be stored in 8 bits, or one byte. Pretty clever, eh? For reference sake, white contains the maximum value of red, green, and blue and has a value of 255, 255, 255. Black is defined as 0, 0, 0. This still doesn't answer the question of what #8a4510 looks like, until you know a bit about hexadecimal.

The hexadecimal system uses a base 16 place order system with “digits” including the numbers 0-9 and the letters a-f (representing decimal values 10-16). Knowing that an RGB designation must have an entry for each of the base colors, you can quickly surmise that by breaking 8a4510 into three hexadecimal numbers and converting them to decimal, that you could find their value in the rgb.txt file above (which uses decimal values for the red, green, and blue values). Converting from hex to decimal by hand isn't very difficult, but here's an even easier way to do it:

Enter bc at the command line to start the bc online calculator, and enter:

ibase=16

This sets the input to base 16 (hexadecimal). Now, enter the numbers that you want to convert to decimal separated by a semicolon:

8A;45;10

You must use capital letters for hexadecimal input. The output should look something like:

138
69
16

Do ctrl-D or type quit to exit bc.

Thus, the red value is 138, green is 69, and blue is 16. Going back to the sample rgb.txt entry above, we can see that this is very close to the entry for SaddleBrown (the blue value in rgb.txt is 19 instead of 16) and this is, in fact, what our color turns out to be.

Now, if all of this seems needlessly complex, rest assured that there are easier ways of viewing and handling colors under X. There are a few must-have configuration utilities that make using and customizing X-Windows a lot easier, and a color viewer such as xcolorsel is one of these. You should be able to find a copy of this very useful program at sunsite.unc.edu (or preferably one of the mirror sites) in the /pub/Linux/X11/xutils/colors/ directory. This very handy program:

1. Shows a color patch and the rgb.txt entry for each color.

2. Displays the color entry in any of 16 different formats, including the hexadecimal notation we've just looked at.

3. Lets the user “grab” a color off the desktop and displays the rgb entry that most closely matches it.

4. Lets the user “preview” what a certain foreground/background color combination might look like using its Set foreground and Set background features.

When you start up xcolorsel, you are initially presented with a display window containing color patches, their corresponding rgb values in decimal notation, and the color name—just as they appear in the rgb.txt file. Clicking on the Display format button presents you with a menu of different formats—choosing 8 bit truncated rgb from this menu lets you view SaddleBrown with its rgb hex value of #8a4510! So, now you can easily see what each color name looks like and, if you're curious, what the hexadecimal notation would be. Thus, the following entries are equivalent:

StdForeColor    SaddleBrown
StdForeColor    saddle brown
StdForeColor    #8a4510

Keep in mind that hexadecimal notation requires the pound, or hash sign (# ) prefix.

Use the Grab color feature to quickly find out what a color's rgb entry is. To do this click on the Grab color button—the cursor will change to a small magnifying glass. Then, position the cursor over any color on your desktop and click once; xcolorsel will display along the bottom status line how many matches or near-matches there are and will highlight the closest entry in the color display window.

Finally, if you want to see what a particular foreground/background color combination might look like, try this: using the mouse pointer, highlight a color you want to use as either the foreground or background color and then hit either the Set foreground or Set background buttons at the bottom. The foreground or background colors of the color display window will then be changed to this value. Hitting the Default colors button reverts the window to its original color scheme.

Now that you've got a bit of a feel for how colors are defined, you can easily create your own customized “window treatments”. However, if you've made changes, started up fvwm, and things still aren't quite the way you'd expected, there still a couple more things you need to know about...

A Word about Styles

One powerful feature of fvwm is that it allows the user to define Styles for any or all applications. The idea is actually a fairly simple one: you can designate how an application window appears and several of its behaviors by setting up a style for it. This can include such things as whether it has a title bar, the size of the window border, whether it has resize handles, what icon it is associated with, and so forth. One such style option, as you might imagine, is color.

The syntax for a Style entry is actually quite simple and might look like:

Style "xterm"  Title, Handles, HandleWidth 7, Icon rxterm.xpm

That is, it begins with the word Style and is followed by the name of the program enclosed in double quotes—in this example, the xterm program. What follows is a comma-separated list of the various style options that you may wish to apply to the program.

Let's suppose you wanted to change the color of an application window to a simple black text on gray background. Simple enough, although it's important to make two points: first, the Styles color entry only sets the colors of the decorative window frames that fvwm puts around the program window—it doesn't change the colors of the application itself. Second, the colors are used when the window is non-selected (that is, it doesn't have the input focus). When the window is selected, the HiForeColor / HiBackColor combination set the color scheme. That said, to change the color scheme when the application window is non-selected you could add an entry such as:

Style "xterm"  Color black/gray, Title, Handles, Icon rxterm.xpm

The syntax is simply the reserved word Color followed by the foreground color name or hex number, a forward slash, and the background color name or hex number. You could also designate each color using the reserved words ForeColor and BackColor:

Style "xterm"  ForeColor black, BackColor gray, Icon rxterm.xpm

Either method will work.

One more quick point about modules and we're done! As previously mentioned, fvwm allows additional functionality to be added using modules such as FvwmPager or the GoodStuff modules. The foreground and background colors of the modules themselves (and not just the decorative window frames as we've been discussing up until this point) can be set using an entry such as:

*GoodStuffFore    black
*GoodStuffBack    turquoise

Configuration lines for modules must begin with the asterisk (*) character, as seen in the example above. To specify the foreground color the module name is given with the Fore suffix. The background color designation uses the Back suffix. In the example above you can see we've changed the color combination to black text on a turquoise background. Again, you can use either the color name or the hexadecimal notation for specifying the color to use.

Well, that should get you going! Obviously, there is a lot more to color customization than the brief overview presented here. For the curious and adventurous, let me refer you to the manual pages for X and fvwm, and the excellent book X-Windows System Administrator's Guide (volume 8 in the X-Windows series) by O'Reilly & Associates publishing. Chapter 6 of this fine reference has a fuller discussion of color and the X-Windows system, including the X-Windows Color Management System (Xcms) that was implemented beginning with release 5. Enjoy!

John Fisk (fiskjm@ctrvax.vanderbilt.edu) After three years as a General Surgery resident and Research Fellow at the Vanderbilt University Medical Center, he decided to “hang up the stethoscope” and pursue a career in Medical Information Management. He's currently a full time student at the Middle Tennessee State University and hopes to complete a graduate degree in Computer Science before entering a Medical Informatics Fellowship. In his dwindling free time he and his wife Faith enjoy hiking and camping in Tennessee's beautiful Great Smoky Mountains. An avid Linux fan since his first Slackware 2.0.0 installation a year and a half ago.