Functions can be called by FVWM though various parts of the config, I will just mention some basic syntax here and then give you some basic functions. For more complicated functions check out the Advanced Topics section.

To start lets take a look at the skeleton of how a function is written. I have it written in a comment block to so you can paste it in your config to be reminded how functions work.

#####
#
# DestroyFunc FuncName
# AddToFunc   FuncName
# + I (Action to happen immediately)
# + C (Action to happen on a mouse 'click)
# + D (Action to happen on a mouse 'double click')
# + H (Action to happen on a mouse 'hold')
# + M (Action to happen on a mouse 'motion')
#
###########

So the first thing you do is destroy the function with DestroyFunc, this will clear the function of anything that may already be applied to it. Then you AddToFunc the list of actions you want it to perform when its called, and as you see above these actions can happen depending on different actions of the mouse. Now when you call a function in FVWM you can send it various parameters. For example you could call the above function as 'FuncName "$0" "$1" "$2" "$3" "$4"' where $0-$4 are options that are passed to the function and can be used in determining the outcome of the function. Now consider the following list of basic functions.

#####
# Basic Functions
###########
DestroyFunc FvwmDeleteOrDestroy
AddToFunc   FvwmDeleteOrDestroy
+ H Nop
+ M Nop
+ C Delete
+ D Destroy

DestroyFunc FvwmIconifyOrShade
AddToFunc   FvwmIconifyOrShade
+ C Iconify
+ D WindowShade

DestroyFunc FvwmMaximize
AddToFunc   FvwmMaximize
+ H Nop
+ M Nop
+ C Maximize $0 $1

DestroyFunc FvwmMoveOrIconify
AddToFunc   FvwmMoveOrIconify
+ M Move
+ D Iconify

DestroyFunc FvwmWindowShade
AddToFunc   FvwmWindowShade
+ D WindowShade $0

The first function FvwmDeleteOrDestroy, will do nothing, NOP, if the mouse is either 'held' or 'moved'. On a single click it will 'Delete' the active window and on a double click it will 'Destroy' the active window. The second function, FvwmIconifyOrShade, will Iconify the window on a single click and shade the window on a double click. The function FvwmMaximized can be sent two values which are then used to determine how the window is maximized. For instance you could call that function 'FvwmMaximize 100 100' and it will maximize the window to fill 100% of your screen both horizontally and vertically, while 'FvwmMaximize 100 0' will maximize the window horizontally but keep its same size vertically. The function FvwmMoveOrIconify will move the current window when the mouse is 'moved' and 'Iconify' on a 'double click'. The FvwmWindowShade function will either shade, 'FvwmWindowShade True', or unshaded, 'FvwmWindowShade False', the current window. If no option is sent to FvwmWindowShade it will shade an unshaded window and unshade a shaded window.

Next I like to write a function to launch all my programs so I can just call the function. These are simple functions, but they keep things a little bit more organized for me. Examples of such functions are;

#####
# Program Launching Functions
###########
DestroyFunc FvwmXTerm
AddToFunc   FvwmXTerm
+ I Exec exec xterm

DestroyFunc FvwmATerm
AddToFunc   FvwmATerm
+ I Exec exec aterm

DestroyFunc FvwmGVim
AddToFunc   FvwmGVim
+ I Exec exec gvim

DestroyFunc FvwmGimp
AddToFunc   FvwmGimp
+ I Exec exec gimp-2.0

DestroyFunc FvwmFireFox
AddToFunc   FvwmFireFox
+ I Exec exec firefox

DestroyFunc FvwmIrssi
AddToFunc   FvwmIrssi
+ I Exec exec aterm -e irssi

DestroyFunc FvwmXmms
AddToFunc   FvwmXmms
+ I Exec exec xmms

DestroyFunc FvwmViewManPage
AddToFunc   FvwmViewManPage
+ I Exec exec xterm -fg White -bg DarkBlue -g 80x40 -fn 7x14 -fb 7x14bold \
 -n "Manual Page - $0" -T "Manual Page - $0" -e man "$0"

The first functions should be self explanatory, and as for the last one, what it does is take a man page as an argument and launches that man page, for example you could call the function as 'FvwmViewManPage fvwm' and it will pop up the man page for fvwm. You should also note the syntax of the last few lines above. At the end of the second to last line there is a '\', that extends that line onto the next one, so FVWM will treat the last two as one line in the config file.

Lets take a look at three special functions, 'StartFunction', 'InitFunction' and 'RestartFunction'. The StartFunction is run each time FVWM is started, while the InitFunction is run after the StartFunction when FVWM is first initialized and the RestartFunction runs after the StartFunction when FVWM is restarted. Examples of such functions are

#####
# Startup Functions
###########
DestroyFunc StartFunction
AddToFunc   StartFunction
+ I Module FvwmTaskBar
+ I Module FvwmPager 0 2
+ I Module FvwmButtons MyButtons

DestroyFunc InitFunction
AddToFunc   InitFunction
+ I Exec exec xscreensaver
+ I Exec exec fvwm-root -r $[fvwm_wallpapers]/background.png
+ I FvwmXmms
+ I FvwmATerm

DestroyFunc RestartFunction
AddToFunc   RestartFunction
+ I Nop

Upon startup fvwm loads the three modules; FvwmButtons, FvwmPager and FvwmTaskBar. When FVWM is first start it starts xscreensaver, sets the background and runs xmms and an aterm. When FVWM Restarts it does nothing (except run the StartFunction)

Functions can be quite detailed and add a lot of usability to your Desktop. Functions can be called with any number of parameters ($0, $1, $2, $3, etc.) and can have any combinations of actions based off of the different mouse events. Functions can use any name that isn't reserved by FVWM for some action, such as Nop, Delete, Destroy, Restart, Exec, etc.

Some other examples of slightly more complex functions are;

#####
# Screenshot Functions (uses ImageMagick)
###########
DestroyFunc FvwmWindowScreenshot
AddToFunc   FvwmWindowScreenshot
+ I ThisWindow (!Shaded !Iconic Iconifiable) \
  Exec import -window $[w.id] -quality 100 -silent \
  "$[fvwm_home]/screenshot/screenshot-`date +%F[%R]`.$[w.id].jpg"

DestroyFunc FvwmDesktopScreenshot
AddToFunc   FvwmDesktopScreenshot
+ I Exec sleep $0; import -window root -quality 100 -silent \
  "$[fvwm_home]/screenshot/screenshot-`date +%F[%R]`.jpg"

#####
# XRoach Invasion
###########
DestroyFunc XRoachInvasion
AddToFunc   XRoachInvasion
+ I Exec exec xroach -roaches 5 -rc Cyan -speed 17
+ I Exec exec xroach -roaches 3 -rc Red -speed 15
+ I Exec exec xroach -roaches 7 -rc Green -speed 10
+ I Exec exec xroach -roaches 3 -rc Blue -speed 20
+ I Exec exec xroach -roaches 1 -rc Black -speed 30
+ I Exec exec xroach -roaches 1 -rc White -speed 40

DestroyFunc XRoachExterminate
AddToFunc   XRoachExterminate
+ I Exec killall xroach

The first set of functions will take screenshots of either the whole desktop or just a single window using the import tool from imagemagick. To take a screenshot of a single window you call the first function with 'Pick (CirculateHit) FvwmWindowScreenshot'. This will give you a pointer and let you 'Pick' what window you want to take the screenshot off. The second function will take a screenshot of your desktop after a '$0' second delay. This is nice cause it will give you time to open up a menu before the screenshot is taken. For example 'FvwmDesktopScreenshot 5' will wait five seconds then take a screen shot. The second set of functions is just an old X toy, it will launch an invasion of different colored 'Roaches' that will scurry across your screen and hide under your windows. You can either call an Invasion of these roaches or Exterminate them all. You will need 'xroach' installed to run these functions successfully.


Global Settings index Bindings