Computer Laboratory

1. Configuration of fvwm2

fvwm2 is configured via a configuration file, .fvwm2rc. There are a few simple examples here:

  • example1 - this has a textured background using this bitmap weird10dark.xpm which you should also download and place in your home directory.
  • example2 - as above but with interesting multicoloured menus (ie this needs weird10dark.xpm too).
  • example3 - simple, different shades of blue, solid background using xsetroot.
In all cases download and rename as .fvwm2rc in your home directory. They are fairly minimal versions, you will probably wish to add extra items to the menus (at least).

Or you could look at one of the fvwm2 web sites and download an off-the-shelf customised version. Note, however, that several major features of fvwm2 have changed during its lifetime (and since fvwm1), so older configuration files are not guaranteed to work properly.

The rest of this page is geared more towards helping you understand a pre-existing .fvwm2rc file than towards helping you to create one from scratch...

Associated with fvwm2 are several separate programs known collectively as Modules. These run as separate Unix processes but can transmit commands to fvwm to execute. They are a means of separating out functionality from fvwm2 itself, and users can (if brave) write their own. Modules must be spawned by the fvwm2 process so that it can set up two pipes for fvwm2 and the module to communicate. Modules can be spawned at any time during the X session with the Module built-in command, so some will be started at fvwm2 startup, while others could be linked to menu options or bound to keys so they can be started at a later stage. Modules can exist for the duration of the X session, or can perform a single task and exit. Particularly useful example modules are FvwmIconMan (the icon manager), FvwmButtons (the button manager, see later), and FvwmPager (the virtual desktop manager). These, and the other modules, each have their own man pages.

Lines in .fvwm2rc beginning with # will be ignored by fvwm2 as comments. Lines starting with * are expected to contain module configuration commands. In addition to the modules, fvwm2 supports a set of built-in functions which can be bound to keyboard or mouse buttons.

1.1 Basic Entries

A few basic entries, which may appear near the top of the .fvwm2rc file:
Style "*"           FocusFollowsMouse
Style "*"           Color lightgrey/dimgrey
HilightColor black palevioletred
WindowFont -adobe-times-bold-r-*-*-18-*-*-*-*-*-*-*
The first line sets the focus: the window with focus is the one receiving input, in this case we have asked for the focus to follow the mouse pointer, one alternative is "ClickToFocus". Unfocused windows use the colour specified on the second Style line, the focused window uses that specified by HilightColor on the third line (the first argument is the text colour, the second is the background), the WindowFont line specifies the font used on window titlebars.

There may be many Style lines - these are used to set attributes of a window to values other than the default or to set the window manager default styles. The format is:
Style windowname options
where windowname can be a window's name, class, or resource string. It can contain the wildcards * and/or ? - as shown above, "*" meaning match all windows. options is a comma separated list containing some or all of the keywords BorderWidth, HandleWidth, NoIcon/Icon, MiniIcon, IconBox, IconGrid, IconFill, NoTitle/Title, NoHandles/Handles, WindowListSkip/WindowListHit, CirculateSkip/CirculateHit, StaysOnTop/StaysPut, Sticky/Slippery, StartIconic/StartNormal, Color, ForeColor, BackColor, StartsOnDesk/StartsOnPage/StartsAnyWhere, IconTitle/NoIconTitle, MWMButtons/FvwmButtons, MWMBorder/FvwmBorder, MWMDecor/NoDecorHint, MWMFunctions/NoFuncHint, HintOverride/NoOverride, NoButton/Button, OLDecor/NoOLDecor, StickyIcon/SlipperyIcon, SmartPlacement/DumbPlacement, RandomPlacement/ActivePlacement, DecorateTransient/NakedTransient, SkipMapping/ShowMapping, UseDecor, UseStyle, NoPPosition/UsePPosition, Lenience/NoLenience, ClickToFocus/SloppyFocus/MouseFocus|FocusFollowsMouse.

They are usually written as a set of lines per windowname for readability, rather than being combined into one big Style line. Some options are listed as style-option/opposite-style-option. The opposite-style-option for entries that have them describes the fvwm default behaviour. For example, in the pair DecorateTransient/NakedTransient the default is NakedTransient (ie don't cause transient windows to be given the standard decorations). Some of the options take arguments - for example Color, as above (forgive the American spellings ...). Color takes two arguments: the first is the window-label text colour and the second is the window decoration's normal background colour. The two colours are separated with a slash. See the fvwm2 manual page for a full description of the Style options.

Some more entries, these concern the virtual desktop:

DeskTopSize 2x2
Style "FvwmPager"   StaysOnTop
*FvwmPagerGeometry -1-1
EdgeScroll 100 100
This indicates that the virtual desktop should be 4 times larger than the screen (ie 2x2), that no other windows should be allowed to cover the Pager window (a small picture of what the overall desktop looks like which is managed by the FvwmPager module), and that the Pager window should be positioned on the bottom right of the screen (ie -1-1, standard X window geometry notation). Note that the geometry line starts with a * - as mentioned above, this means it is a module configuration command. You can move between the parts of the virtual desktop either by clicking on the relevant part in the Pager window, or by simply moving the mouse pointer off the edge of your screen. The EdgeScroll entry indicates that in such cases the desktop shifts by an entire screen when the pointer goes over an edge.

As can be seen Style entries can also control attributes of the various modules of fvwm2 itself, but it can also cover other programs specified by the first argument. Thus although we have said that the default colour for unfocused windows is a rather boring lightgrey/dimgrey combination, we can change this, and also specify other useful behaviour:

Style "xclock"      Sticky, StaysOnTop,  Color Gold3/Turquoise4	   
Sticky means that xclock should appear in the same place on all of our virtual desktop screens.

1.2 Button Bindings

fvwm2 allows binding of mouse buttons to any desired functions, for example:
Mouse 1	R   	A       Menu RootMenu Nop
Mouse 2	R    	A      	Menu Window-Ops Nop
Mouse 3	R    	A      	WindowList
The format is
Mouse button context modifiers function
where button is 1,2,3 or 0 (= any button).
context is one or more of:
  • R root window
  • W application window
  • S windowframe
  • F windowframe corner
  • T windowtitlebar
  • I icon window
  • 0-9 titlebar buttons, those on the left are odd numbers, those on the right are even, in both cases increasing from left to right. binding functions to a button causes them to appear, they are otherwise invisible.
  • A any context other than titlebar buttons
modifiers are keys that may be combined with a mouse button: C for control, M for Meta, S for Shift, N for none, A for any of the above.

Thus in the example given: Mouse 1 R A Menu RootMenu Nop, Mouse button 1 on the root window with any modifying key causes the RootMenu menu to appear (with an argument of Nop, ie none).

We can also specify what goes into the menus that we have caused to pop up by using the AddToMenu command:
AddToMenu RootMenu	"Root Menu"	Title
+                       "Utilities"     Popup Utilities
+			"Exit Fvwm"	Popup Quit-Verify

AddToMenu Utilities     "Utilities" Title
+			"Calculator"	Exec exec xcalc
+			"Clock"		Exec exec xclock
+			"Digital Clock"	Exec exec xclock -digital

AddToMenu Quit-Verify 	"Really Quit Fvwm?" Title	
+		      	"Yes, Really Quit"  Quit	
+		      	"No, Don't Quit"    Nop	
This would give us a very simple RootMenu with two options, both of which bought up further menus, one to start utilities, the other to check whether you really wanted to quit fvwm2.

1.4 InitFunction

You can have fvwm fill in a background colour of your choice by using InitFunction and xsetroot, for example:
AddToFunc InitFunction    "I" Module FvwmButtons
+                         "I" exec xsetroot -mod 2 2 -fg \#554055 -bg \#705070
which will give you a rather nasty dark plum colour with a textured grid over the top (this is the setting in the default system.fvwm2rc file). This is an illustration of the InitFunction builtin command, which can be used to perform functions when fvwm2 starts up. In this case it will also start the FvwmButtons module, which is rather useful (see below). Or you can have a picture in your background using xpmroot, xv, or in this case display:
AddToFunc InitFunction    "I" Module FvwmButtons
+                         "I" exec display -window root /homes/youruserid/somepicture
where somepicture is an image of your choice in a format that display can display (almost anything).

1.5 Buttons

The FvwmButtons module puts together a set of buttons which sit permanently on your desktop, and which makes a useful place to put the Icon manager, the Pager, and assorted other utilities. As a full example:
################## FvwmButtons button-bar ################################
*FvwmButtonsGeometry 520x100-1-1
*FvwmButtonsBack bisque3
*FvwmButtons(Frame 2 Padding 2 2 Container(Rows 2 Columns 5 Frame 1 \
                                           Padding 10 0))
*FvwmButtons(3x2 Frame 2 Swallow "FvwmIconMan" "Module FvwmIconMan")
*FvwmButtons(1x2 Frame 2 Swallow(UseOld) "FvwmPager" "Module FvwmPager 0 0")
*FvwmButtons(1x2 Frame 0 Container(Rows 2 Columns 2 Frame 0))
*FvwmButtons(Frame 2 Swallow(UseOld,NoHints,Respawn) "xbiff" `Exec exec xbiff -bg bisque3`)
*FvwmButtons(Frame 3 Swallow(UseOld,NoHints,Respawn) "xclock" `Exec exec xclock -bg bisque3 \
                                           -fg black -hd black -hl black -padding 0 -update 1`)
*FvwmButtons(2x1 Frame 2 Swallow(UseOld,NoHints,Respawn) "xload" `Exec exec xload -bg bisque3 \
                                           -fg black -update 5 -nolabel`)
which looks quite complicated. The first two lines just set up the size, position and colour of the FvwmButtons area. It then creates a container to put things in. It puts in (from left to right) the FvwmIconMan icon manager (which process it spawns using the Module command), the FvwmPager (again, spawned with Module), and creates another nested container. It puts xbiff, xclock and xload windows into this nested container. The outer container is 2 rows x 5 columns big. From left to right, the FvwmIconMan takes up 3 columns x 2 rows (hence the 3x2 option), the FvwmPager takes up 1 column x 2 rows, which leaves 1 column x 2 rows for the nested container. This is 2 rows x 2 columns big. In this (from left to right and top to bottom) xbiff takes up 1 column x 1 row (the 1x1 option is implied), xclock takes up 1 column x 1 row, and xload takes up the remaining space (which is 2 columns x 1 row).

Frame {num} sets the width of the frame around an item.
Padding sets the amount of free space between the relief of the button and its contents.
Swallow {options} {hangon} {command} causes a command to be executed, and when a window by the name of hangon appears it is captured and its output appears within this button. eg
Swallow(UseOld,NoHints,Respawn) "xbiff" `Exec exec xbiff -bg bisque3`
means execute the command exec xbiff -bg bisque3, which would normally result in the appearance of a separate window called xbiff, however the swallow command causes fvwm2 to grab the output of this window and display it within the button rather than as a separate window. The options used in this case mean:

Specifies that the button will try to swallow an existing window matching the hangon name before spawning one itself with command,
Specifies that hints from the swallowed program in this button will be ignored, which will force a window to resize itself to fit its button,
Specifies that the swallowed program is to be re-spawned (re-started) if it dies.
See the FvwmButtons manual page for the full list of options.