How to call a function defined in fvwm when a window X is opening or closing?

How to call a function defined in fvwm, when a window X is opening or closing?

The FvwmEvent module can do this. Example:

DestroyModuleConfig FvwmEvent
*FvwmEvent: Cmd
*FvwmEvent: Delay	0
*FvwmEvent: StartDelay	2
*FvwmEvent: add_window		EvtWinAdd

DestroyFunc	EvtWinAdd
AddToFunc	EvtWinAdd
# called by FvwmEvent when any new window is created
# we check for a handful of windows, and perform actions for those
+ I ThisWindow ("xterm") WarpToWindow
+ I ThisWindow ("kcalc") WarpToWindow
+ I ThisWindow ("Emacs") WarpToWindow

For opening you can also use the IntialMapCommand style. Closing you’ll have to use FvwmEvent.