Customizing FVWM

2699
FVWM, the F Virtual Windows Manager, is a window manager for computers running the X Window System. While KDE and GNOME offer more features, they are also heavy on memory usage. FVWM is light and fast, and you can customize it to meet your needs, and apply these customizations throughout your organization.

The default FVWM screen is very basic — just a simple blue desktop. Clicking anywhere with the left mouse button brings up a menu with a couple of built-in options, including xterm. You can also move around the virtual desktop by moving mouse cursor off the edge of the screen (you’ll find there are nine ‘screens’ in a 3×3 grid). And there you have it — simple, light, and very fast.

You want more? Let’s put in some window control.

Basic FVWM customization

FVWM uses the file ~/.fvwm/.fvwm2rc to override its default configuration. Create this file with the following contents:

Mouse 0 1 A Iconify
Mouse 0 2 A Maximize 100 100

Style "*" NoIcon
EdgeResistance 1000 0

Style "FvwmTaskBar" NoTitle,BorderWidth 0,HandleWidth 0,Sticky
AddToFunc InitFunction I Module FvwmTaskBar
AddToFunc RestartFunction I Module FvwmTaskBar

In this file, the first two lines create a maximize and minimize button for all windows. The next line switches off the icons for minimised applications. Put a hash mark at the start of the line if you want to see what the icons look like; personally, I think they clutter up the screen too much. The EdgeResistance setting slows down the changing from one screen to another. A value of 1000 means 1 second; i.e. you must hold the mouse cursor at the edge of the screen for one second before the screen will switch. If you want only one screen then put this value very high (e.g. 100000). Finally, the last three lines create a task bar at the bottom of the screen.

In order to see your changes you must restart FVWM. Left-click on the main screen, then select Restart FVWM.

Once the screen has refreshed itself you should see a task bar at the bottom of the screen, complete with a Start button. It has no functionality at the moment, but we can add some by adding the following to the file:

AddToMenu "Internet" "Internet" Title
+ "Firefox%mini-x.xpm%" Exec firefox &
+ "Thunderbird%mini-x.xpm%" Exec thunderbird &

AddToMenu "Main" "Main" Title
+ "xterm%mini-x.xpm%" Exec xterm &
+ "Internet%mini-x2.xpm%" Popup Internet
+ "Restart%mini-turn.xpm%" Restart
+ "Quit%mini-exclam.xpm%" Quit

*FvwmTaskBarStartMenu Main

This code includes a Main menu containing xterm, a sub-menu for Internet applications, the restart function, and an Exit button. If you now restart FVWM then you will find that the Start button has this new popup menu associated with it. You can build up your own set of menus to run the applications that you need.

In addition to the Start menu we can also customize the default Builtin Menu that’s accessible by clicking the left mouse anywhere on the main screen. We can also add some functionality to the right mouse button, which does nothing at the moment. Add the following code to ~/.fvwm/.fvwm2rc:

Mouse 1 R A Menu Main
Mouse 3 R A Menu Internet

A left mouse click will now invoke the Main function instead of the Builtin Menu, whilst the right one will show the Internet menu. In this way you can build up a Windows Manager that has all of the applications that you require.

Interacting with the shell

So for we have only looked at static menus — that is, those that are hard-coded into the file. However, you can also build dynamic menus based on shell commands. To do this use the Piperead command:

AddToMenu ListFiles ListFiles Title
Piperead `for f in ~/*.html; do echo "+ $f Exec gedit $f"; done`

This simple example builds a menu listing all of the HTML files in your home directory, and allows you to access them using gedit.

Using FVWM within an organization

We’ve seen how FVWM allows you to have all your key applications at your fingertips. Once you’ve done that for one system, you can easily deploy your changes across an organization. You can set up .fvwm2rc files according to a person’s function with the organization — a developer doesn’t need to see the same menus as his manager. The manager doesn’t need to see the same things as her directors. The directors just need to see the things that will keep them happy.

This can be addressed in a few ways. The most obvious way would be to copy the customized .fvwm2rc file into each person’s .fvwm directory according to what they need to see. This works well, but if you make any changes to the main .fvwm2rc files, you’ve then got the headache of remembering who has which file, and then rolling it out to them.

A better way is to create a link from the user’s .fvwm directory to a central file:

ln -s /etc/FVWM/.fvwm2rc_user .fvwm2rc

However, the best approach is to make use of Piperead, the Linux groups command, and the FVWM Read function. The Read command lets you include a second config file. Each user’s .fvwm2rc needs to contain only the following line:

Piperead "echo Read /etc/FVWM/.fvwm2rc_$(groups|awk '{print $1}')"

The .fvwm2rc file will look up a user’s group and load the appropriate file. This, of course, assumes that you have created the directory /etc/FVWM and that it contains a set of files called .fvwm2rc_users, .fvwm2rc_root and so on — one for each group.

In this article we’ve looked only at FVWM’s most basic functionality. We’ve not looked at fonts, colours, FVWM’s buttons, or dynamic menus. The FVWM Web site presents an excellent section (under Screenshots) with a vast array of configurations that may give you some inspiration. If you try some, before long you will have a professional, well-designed window manager you can use throughout your organization.