Introduction

This guide will tell you how to write your own configuration file for FVWM. This is not an easy step (this is almost more
programming than editing), and if you'd just like something quick and easy, or don't even have FVWM installed yet, I'd suggest you read FVWM.

Starting Up

From a Console

You can get into FVWM pretty quickly by at a console:

XSESSION=fvwm2 startx -- :1 vt8

This is done so that should something go wrong, we can still startx, and get into our normal desktop to get some help, or just get back to life for a while.

To get back into FVWM after switching away, hit Ctrl + Alt +
F8.

From KDM

You need to place fvwm.desktop in /usr/share/xsessions/

Setting up our Basics

This howto is a guide, with the word "Advanced" in the name. As such,
you are expected to tweak as you go. Your final config will probably look quite different from mine (especially if you're a KDE person :-p).

I've seen way too many FVWM configuration files that are insanely
complex, and to make one change, you have to go through a few hundred or
thousand of lines of code. We're going to keep this simple and logical.
Modular would be a good way to describe our configuration. The default configuration file is called ~/.fvwm/config (or ~/.fvwm/.fvwm2rc for versions prior to 2.5.10). From this file the modular configuration will be read by the command Read. For example, we can define a pager in the file ~/.fvwm/pager and read it from config.

Read pager

You'll always have to keep in mind that if you don't understand something, you can read the man pages: You can reach the main man page with:

man fvwm

At the beginning you will need frequent access to fvwm man pages. You could follow these instructions to have fvwm man pages in your menu. If you use KDE applications you could also use khelpcenter to read man pages. The Official FVWM Home Page has a handy man page with hyperlinks.

Commands, Functions and Modules

To start, FVWM reads the config file (and all files read by config). After reading the whole of the configuration it executes StartFunction (if defined) and then InitFunction (if defined).

Commands refer both to configuration commands. Look at the list of fvwm commands. The following command defines a desktop sixe of 3x2 pages.

DesktopSize 3x2

Modules. As the man page states, a module is a separate program which runs as a separate Unix process but transmits commands to FVWM to execute. FVWM comes with a pre-defined number of modules, and you will find here the commands to configure them. For example, the FVWM man page mentions FvwmBacker as the module that changes the background when you change desktops. First, you have a look at the man page of FvwmBacker to know its syntax.

# man FvwmBacker

Now, you can define FvwmBacker. This example defines six different backgrounds for the pages defined by the previous DesktopSize command.

In the next example, the commandStyle defines the style (where and how) of FvwmButtons module with alias Confi (you can have different FvwmButtons running with different alias). The style defines that the module will appear on page 0,0, without the buttons 1,2 and 4, and it will not show in the window list of active programmes. The definition of the module Confi follows.

A function is a collection of commands that performs a specific task. FVWM has its own default functions (like StartFunction). Typically, where a function defines a set of rules, they're called a complex function.

Order of Execution. As it is stated in this and this post, the order of execution of the config file is the following:

Kontact will start on Page 0,1,0 despite the commandStyle is posterior to the functionStartFunction.
The prefix function and module tells fvwm the type of object. If the prefix is omitted, fvwm will try to match it following this order (fvwm man page):

1. Match it to one of its internal commands.
2. Match it to a function name.
3. Match it to a module.

StartUp Applications

FVWM has initialisation functions. StartFunction is executed on startups and restarts. If you have FVWM 2.5.X you can also use StartFunction for Init and Reboot (see this thread). You can add modules and applications to start up with fvwm including them to your ~/.fvwm/config file:
In this example, StartFunction is used for Init applications.

Alternatively, there is already a heap of menu definitions supplied by the programs that you install, just that FVWM doesn't know how to read them (yet). The format for these is defined by the Freedesktop standard, and there's a very useful script available from the Fvwm Wiki for creating an automatically generated menu from these definitions.

Even better, with a few modifications this script can be used to create the Icon and MiniIcon styles for the programs defined this way, making it much easier to set up some default styles for your programs.

To include the generated menu in your own menus, you need to read in the output from this file and then include the 'Gnome2Menu' menu that it generates. To do this, open the file ~/.fvwm/menus for editing again, and add to the top:

Loading Menus and Mouse

From now on, ~/.fvwm/.fvwm2rc will be used only for the most
basic of functions. But feel free to change the layout to your liking, as
FVWM allows you to configure it just for you.

Icons

If you used the automatic menu generation, there are some icons defined for the Icon and MiniIcon style for each program that has a menu entry. These can be used for things like viewing in the taskbar, or as a button at the top of each window, but FVWM needs to know where to look for the icons, and they need to actually be there.

To define the path(s) to look for icons, use the 'ImagePath' directive in your ~/.fvwm/.fvwm2rc file as follows:

Multiple search directories can be chained together, and it will use the first instance of a file that matches the specified filename that it finds in the path. The '+' sign at the end indicates that anything that was already defined for the ImagePath should be appended to the end of this listing.

The problem with this is that many icons will not yet be present - or the mmain, fullsize icon will be but the mini-icon version will not. To fix this, you'll need to go and convert each icon in use to include a mini icon.

This will create a mini icon in /usr/share/pixmaps/mini of size 20x20 (change it to whatever size you prefer) for every png and xpm format icon in the /usr/share/pixmaps directory.

Likewise, you can use the icons from gnome or kde definitions by copying a 'base' icon to a known location (e.g. your personal directory ${HOME}/.fvwm/icons/personal), then as yourself running the conversion script (which comes from the package imagemagik).

Create as many specific sets of icons as you like, and just add the additional directories to your ImagePath.

Using Icon Styles

Icons can now be included in your menus, and added to the title bar for each program if you wish.

For menus, this is controlled by the MenuStyle ItemFormat option, which shoud be kept with the rest of your MenuStyle options so that it's easy to find (the ~/.fvwm/Menus file if you've followed the earlier instructions).

An example setting would be:

MenuStyle * ItemFormat "|%.5i%.5l%.5i%2.3>%2|"

which gives an item icon, the name of the menu entry, followed by a possible second icon, followed by an arrow if the menu entry opens up a new menu.

If no icon was specified for the menu entry, it just leaves a blank space.

Using icons in the title bar is done through the ButtonStyle <num> MiniIcon option. To set the first button (the left-hand one) of the titlebar to use the MiniIcon defined for the program, add a line to ~/.fvwm/fvwm2rc as follows:

System Tray

Fvwm does not have a default system tray. Applications that can be "minimized to the tray" usually appear on its own window (see this thread). In case you need a system tray you can choose between system trays like trayer or stalonetray. You can start stalonetray in your StartFuntion:

Automount

Fvwm does not automount devices, but you can easily create udev rules offering this (and many other) function. There are different examples in the Auto Mount Filesystems of the Gentoo Wiki.

Basic Controls

If you haven't discovered it yet, FVWM allows you to have multiple workspaces arranged into a 3x3 grid (but that's adjustable). This is one of the reasons I love FVWM. You don't have to move your mouse to some control to switch desktops, you just move to the edge of the screen. We're also going to establish some defaults, and our default programs. If you have a lot of programs you like to load on default, you may want to tell FVWM only to load it once. In your StartFunction,
you can do:

There are two types of buttons that can be defined: vector buttons (used by default) and pixmaps. You can find examples of vector buttons definitions here, and here explains its logic so you can create them. From the vector button examples, the definition of button 1 could be:

Module configuration

Styles

Localization

I get in troubles in my system that use 2 locales: en_GB.UTF-8 for root in order to get English messages with portage and fr_CH.UTF-8 as user. The problem was at I launch FVWM with gdm and at I have a function in my FVWM config that call a bash script that have some locale dependent action (I also have localized menus). By setting the user locale in ~/.bashrc and without any ~/.profile, I get my localized menu in french when using my French locale and the script was running fine, but when shifting to English locale, my menu was still in French and the script was completely confused. The solution was to use the same locale in both ~/.bashrc and ~/.profile.