...making Linux just a little more fun!

<-- prev | next -->

# Fvwm

By Thomas Adam

### Introduction

Fvwm! I'm sure some of you remember it quite well as a window manager of the days past - and you'd be forgiven for thinking that it no longer existed. It is, perhaps, a shame that it has been over-shadowed by the newer, glitzier desktop managers such as KDE and GNOME, but I suppose that the times have changed. People are after more eye-candy than even before - right? Well, not me. While it may be true that we all like pretty things, often these things come with a sacrifice. The most noteworthy thing for me over the years has been that using KDE and GNOME requires a supercomputer with tons of RAM, while Fvwm remains fast as lighting on machines with even marginal resources. For those of us who wish to get full usage out of our existing hardware instead of chasing the ever-changing "latest and greatest" machinery with our hard-earned cash, software such as Fvwm can be the factor that makes the key difference.

What separates a window manager from a desktop environment is that the former does not have integrated applications such as file managers and utilities to tweak the overall environment. Instead, all such utilities are external - just as they should be. The job of a window manager is just that; it manages windows.

Fvwm was created by Robert Nation. It is based on code from 'twm' (Tom's Window Manager) which was at the time perhaps the only real window manager available. Frustrated with the lack of features and the fact that 'twm' was full of memory leaks, Rob began hacking on it; the result was that Fvwm was kick-started in early 1993. Rob had, in fact, already made a name for himself as the author of the popular terminal emulator rxvt, which is still used by a lot of people today.

What I intend to demonstrate here is how to start from a minimal configuration of Fvwm and work upwards, discussing how Fvwm operates and how to configure it to do various things. There is a lot to Fvwm, so this won't be quick - but I hope it will be interesting nevertheless.

### Installation

Since Fvwm has been bundled with every distribution that I have used, chances that you have it anyway. You should not use Fvwm1, since this is old and is no longer supported by the developers. Currently, the stable version is 2.4.18 while the unstable version is 2.5.10. Unlike many classifications of stable/unstable, the unstable version of Fvwm has never crashed for me, so I can recommend using it. Indeed, most of what I will talk about over the next few months will rely on the features in this version, and that are absent in the 'stable' version.

As a side note to using pre-compiled binaries, depending on the distribution used, some features that I may mention might not be compiled in. Therefore, if you want to have all the features that I'll be discussing, you would be well advised to download the unstable version and compile it. There's plenty of helpful information in the README and INSTALL files.

### Features of Fvwm

There are too many features to list, but as an overview of what Fvwm provides, here are some of the more interesting ones:

- Full Enhanced Window Manager Hints support
- Virtual Desktops
- Full internationalisation
- Greatly improved font support, including anti-aliasing
- Improved decoration code
- Side titles, including vertical text
- Powerful WindowShade in all directions, including diagonal
- PNG support, including alpha blending
- Image rendering in colorsets
- Perl library for creating modules in Perl
- New module FvwmPerl to enable scripting in rc files
- Optional text shadows (looks nice with light text)

There is also session management support for those who want it.

### Starting and Configuring Fvwm

Fvwm's configuration is best done on a per-user basis, although a global configuration is possible. When Fvwm loads, it looks for the following files and will use the first one it finds:

- $HOME/.fvwm/config
- /usr/local/share/fvwm/config
- $HOME/.fvwm/.fvwm2rc
- $HOME/.fvwm2rc
- /usr/local/share/fvwm/.fvwm2rc
- /usr/local/share/fvwm/system.fvwm2rc
- /etc/system.fvwm2rc

If no files are found, Fvwm loads with a default builtin menu. This can initially be used to create a basic ~/.fvwm/.fvwm2rc file, as shown by figure 1.

Figure 1: Fallback mode that Fvwm uses if no config files were found.

You can then reload Fvwm, and you'll have a bare-minimum config file. By default, Fvwm takes on the appearance of mwm and although mwm's style can be emulated completely, Fvwm's own internal style is to have raised borders and a raised title, as shown in figure 2.

Figure 2: Screenshot of the settings produced after the generated config.

You may well be thinking "yuck!" - and I wouldn't blame you. There are certain things about it that are hideous, I know. But everything you see in the screenshot is configurable. Of course, all actual window management features are supported; there are menus, button bars, etc. Let's take a closer look at what makes up a window.

### A window is a window is a window

A window is a decorated screen frame containing the graphical interface of a program. There are several characteristics of a window, some of which are obvious and some not so obvious, all of which allow us to configure the window's appearance. The structure of a typical window usually contains the following:

- Title Bar
- Window Buttons
- Window Border

A popular configuration is to have three buttons on the title bar. The leftmost one when clicked, pulls down a menu of choice that can be applied to the window. This is more or less the same as the decor in MS-Windows. The next button after that (moving right) iconifies the window, while the button next to that one maximises the window (as seen in Figure 3).

Figure 3: A decorated window using the default Fvwm settings.

Fvwm allows up to a maximum of ten buttons on the window titlebar. These can be defined to perform a number of functions. I've yet to personally think of a reason why you would need to define all ten, but I'm sure some people do. There are two types of buttons that can be defined: vector buttons and pixmaps, the former of which are used by default. I'll come back to the difference later on, but for now we'll look at how the buttons are arranged and seen by Fvwm. As such, each button is numbered in turn.

    +--------------------------------------------------------------------------+
    | 1 3 5 7 9			   Title			 0 8 6 4 2 |
    |--------------------------------------------------------------------------|
    |									   |

Fig. 3 therefore shows that buttons 1,4 and 2 have been defined. I mentioned vector buttons earlier. These are "drawn" by Fvwm. Essentially, they're just coordinates of points used by Fvwm for specific functions. You can see a huge list of vector definitions here. You can also apply various definitions to the buttons as you see fit. The code for the buttons is defined within a decor. By default (as is the case here), if no decor has been defined, the builtin is used.

#### Defining Decors

A decor is a defined set of characteristics that can be applied to windows. Typically, they're suited for defining all the attributes we've looked at so far.

    AddToDecor   fDecor
     + BorderStyle Simple
     + TitleStyle	   -- Raised
     + ButtonStyle All -- Raised
     + AddButtonStyle 1 Vector 5 25x40@1 25x60@1 75x60@0 75x40@0 25x40@1
     + AddButtonStyle 2 Vector 4 50x25@1 75x75@0 25x75@0 50x25@1
     + AddButtonStyle 4 Vector 4 50x75@1 25x25@1 75x25@1 50x75@0
     + ButtonStyle	  1 - Clear MWMDecorMenu
     + ButtonStyle	  2 - Clear MWMDecorMax
     + ButtonStyle	  4 - Clear MWMDecorMin

This code can be placed in the ~/.fvwm/.fvwm2rc file. This decor does a number of things. BorderStyle sets up the style of the border. The simple option tells Fvwm that you want the defaults. If you look closely at the border, you'll notice that the edges are cut into. These are the window handles that define how much of the edge is available for grabbing the window (to resize it, move it, etc.) TitleStyle can set a number of attributes; here, it is being used to give the tilebar a raised look, and the same is done to the buttons with the ButtonStyle command. AddButtonStyle adds to an existing style. Following that, the button number is specified (see diagram), and last are the vector definitions that you can replace with your own.

One aspect you must be aware of is that if you define a new button to be added to the titlebar, you must give it a mouse-binding, otherwise it will not display. I won't be covering mouse bindings just yet, but for now you can locate the following in the ~/.fvwm/.fvwm2rc file:

    #   for the title bar buttons:
    Mouse 0 1       A       Menu MenuFvwmWindowOps2 Close
    Mouse 0 2       A       FuncFvwmMaximize
    Mouse 0 4       A       Iconify

Adding your own definition is simple. Although nothing will be bound to the button, you can add below those definitions something like the following, replacing the number after "0" with the corresponding number of the button for which you have defined the vector:

    Mouse 0 0	A	Nop

You'll have to restart Fvwm for the changes to be applied.

There is a huge number of options available for just these commands. For instance, you can define the Titlebar to be flat, by adding the following line:

    TitleStyle -- Flat

If you add --flat to the end of your vector button definitions, the button takes on a sunken, rather than raised, appearance. You can also define button styles based on state, i.e. one for ActiveUp and ActiveDown. Border styles can also be set, so that, rather than a raised border, you can have sunken or flat ones.

As I mentioned earlier, pixmaps can also be used, in place of vector buttons. The same rules apply about defining the mouse-bindings from earlier. These are .xpm files that you can define to replace the buttons with images of your own. The style is similar to the one just defined:

    ButtonStyle 2 Pixmap my_pixmap.xpm
    ButtonStyle 4 \
      ActiveUp   (Pixmap activeup.xpm) \
      ActiveDown (Pixmap activedown.xpm) \
      Inactive   (Pixmap inactiveup.xpm)
      ButtonStyle 4 \
      InactiveDown Pixmap inactivedown.xpm

Here, Button 2 remains the same throughout all states, but Button 4 uses a different pixmap depending on the state. The button states are listed below:

- ActiveUp -- This is the default used, if nothing else is set. It cannot be destroyed.
- ActiveDown -- This is the state of the button when it is pressed in.
- InActive -- This is used for windows that are focused and defocused (hence the ActiveUp state is used).
- InactiveDown -- Used for button/title presses for non-focused windows.

To apply the decor that you create, you have to tell Fvwm about it. The following general line can be used, obviously replacing the name of the decor with whatever you called it. In the examples above it is fDecor:

    Style *  UseDecor  fDecor

### Next Month...

Obviously, this has been a cursory review of what a window is, and how to define the basic decor such as buttons and borders. There is a plethora of options that I have not covered just for these alone. Although somewhat cumbersome, the man page for fvwm contains all of these, and includes a lot of options in addition to what I have mentioned. Play around and experiment with defining buttons and vectors.

Next month, we'll take a look at defining menus, coloursets for windows, and some other style options.

### Resources

Here's a list of resources for more Fvwm-related information:

FVWM's official site
Fvwm Decor collection
fvwm-themes site
An excellent and "modern" fvwm2rc file
Fvwm screenshots
Calmar's site about Fvwm
My own config file with screenshots

`man fvwm`

I write the recently-revived series "The Linux Weekend Mechanic", which was started by John Fisk (the founder of Linux Gazette) in 1996 and continued until 1998. I'm also a member of The Answer Gang.

I was born in Hammersmith (London UK) in 1983. When I was 13, I moved to the sleepy, thatched roofed, village of East Chaldon in the county of Dorset. I am very near the coast (at Lulworth Cove) which is where I used to work.

I first got interested in Linux in 1996 having seen a review of it in a magazine (Slackware 2.0). I was fed up with the instability that the then-new operating system Win95 had and so I decided to give it a go. Slackware 2.0 was great. I have been a massive Linux enthusiast ever since. I ended up with running SuSE on both my desktop and laptop computers.

While at school (The Purbeck School, Wareham in Dorset), I was actively involved in setting up two Linux proxy servers (each running Squid and SquidGuard). I also set up numerous BASH scripts which allowed web-based filtering to be done via e-mail, so that when an e-mail was received, the contents of it were added to the filter file. (Good old BASH -- I love it)

I am now 18 and studying at University (Southampton Institute, UK), on a course called HND Business Information Technology (BIT). So far, it's great.

Other hobbies include reading. I especially enjoy reading plays (Henrik Ibsen, Chekhov, George Bernard Shaw), and I also enjoy literature (Edgar Allan Poe, Charles Dickens, Jane Austin to name but a few).

I enjoy walking, and often go on holiday to the Lake District, to a place called Keswick. There are numerous "mountains", of which "Great Gable" is my most favourite.

I am also a keen musician. I play the piano in my spare time.

I listen to a variety of music. I enjoy listening to Rock (My favourite band is "Pavement" (lead singer: Stephen Malkmus). I also have a passion for 1960's psychedelic music (I hope to purchase a copy of "Nuggets" reeeeaaall soon).

Copyright © 2004, Thomas Adam. Released under the Open Publication license

Published in Issue 105 of Linux Gazette, August 2004

<-- prev | next -->