= FvwmEvent(1)

:doctype: manpage
:mantitle: FvwmEvent
:manname: FvwmEvent
:manmanual: Fvwm Modules
:manvolnum: 1
:page-layout: base

== NAME

FvwmEvent - the fvwm event module

== DESCRIPTION

_FvwmEvent_ is a module that triggers actions on _fvwm_ events.
It can be used to hook any _fvwm_ function or program to any window
manager event. _FvwmEvent_ can trigger actions when windows are
added, deleted, iconified, shaded, or when _fvwm_ changes which
virtual page or desk is being shown, or when RandR monitors are
changed, enabled, disabled, or gain focus. Be creative, you'll
find a use for it.

== INVOCATION

_FvwmEvent_ is spawned by _fvwm_, so no command line invocation will
work. _FvwmEvent_ can be spawned from within the _config_ file
with or without an _Alias_ as follows:

....
Module FvwmEvent Alias
....

You can add this to the _StartFunction_ to ensure _FvwmEvent_
is running and listening for events when _fvwm_ starts. Alternatively
you can add this to a menu, key binding, etc. You can kill stop
a running instance of _FvwmEvent_ with:

....
KillModule FvwmEvent Alias
....

== CONFIGURATION OPTIONS

_FvwmEvent_ gets config info from *fvwm*'s module configuration database
(see _fvwm_(1), section *MODULE COMMANDS*), and looks for certain
configuration options:

*FvwmEvent: Cmd command::
  This determines the _fvwm_ function that is to be called with the
  event parameters. You might want to do one of the following (details
  below):
+
....
	# execute distinct fvwm functions
	*FvwmEvent: Cmd

	# execute distinct external programs
	*FvwmEvent: Cmd exec
....
+
_FvwmEvent_ has support for any other external program. e.g: the
rsynth 'say' command:
+
....
	*FvwmEvent: Cmd "Exec /rsynth/say"
	*FvwmEvent: destroy_window "window closed"
....
+
You can also use _fvwm_'s builtin _Echo_ command as _FvwmEvent: Cmd_ to
obtain debug output for _fvwm_ events quietly. I used this setup to
debug FvwmAuto:
+
....
	*FvwmEvent: Cmd Echo
	*FvwmEvent: focus_change "focus change"
	*FvwmEvent: raise_window "raise window"
....
+
You can even call different shell commands for each event just by
setting
+
....
	*FvwmEvent: Cmd exec
	*FvwmEvent: add_window 'killname "APPL ERROR"'
....

*FvwmEvent: PassId::
  Specifies that the event action will have an ID parameter added to the
  end of the command line. Most events will have the windowID of the
  window that the event refers to. The new_desk event will have the new
  desk number. Monitor events will have the RandR monitor name. The
  windowID is a hexadecimal string preceded by 0x, desk numbers are
  decimal, and monitor name's are strings.

*FvwmEvent: window-manager-event action::
  Binds particular actions to window manager events. The action is
  appended to the _Cmd_ which is then sent to _fvwm_ for execution.
+
The following events are valid:
+
[cols="<,<",]
|===
|_Event_ 		|_Description_
|add_window 		| Occurs when a new window is mapped and visible
|config_info 		| Occurs when a module asks for configuration
|configure_window 	| Occurs when a ConfigureNotify event happens
|default_icon 		| Occurs when a window's DefaultIcon changes
|deiconify 		| Occurs when a window id deiconified
|destroy_window 	| Occurs when a window is destroyed
|dewindowshade 		| Occurs when a window is unshaded
|echo 			| Occurs when an Echo command is run
|end_config_info 	| Occurs when there's no more module config to send
|end_windowlist 	| Occurs when the windowlist has finished sending
|enter_window 		| Occurs when a window receives a EnterNotify event
|error 			| DEPRECATED
|focus_change 		| Occurs when a window gains or loses focus
|icon_file 		| DEPRECATED
|icon_location 		| DEPRECATED
|icon_name 		| DEPRECATED
|iconify 		| Occurs when a window is iconified
|leave_window 		| Occurs when a window receives a LeaveNotify event
|lower_window 		| Occurs when a window is lowered
|map 			| Occurs when a window is Mapped
|mini_icon 		| Occurs when a window's mini icon changes
|monitor_changed 	| Occurs when a monitor's resolution changes
|monitor_disabled 	| Occurs when a monitor is disabled (via RandR)
|monitor_enabled 	| Occurs when a monitor is enabled (via RandR)
|monitor_focus 		| Occurs when a monitor gains focus
|new_desk 		| Occurs when a new desk is switched to
|new_page 		| Occurs when a new page is switched to
|old_add_window 	| DEPRECATED
|old_configure_window 	| DEPRECATED
|property_change 	| Occurs when a window receives a PropertNotify event
|raise_window 		| Occurs when a window is raised
|res_class 		| Occurs when a window's Class is set
|res_name 		| Occurs when a window's Resource is set
|restack 		| Occurs when windows are restacked
|sendconfig 		| Occurs when FvwmEvent asks for its config
|shutdown 		| DEPRECATED
|startup 		| DEPRECATED
|string 		| Occurs when the SendToModule command is used
|unknown 		| DEPRECATED
|visible_icon_name 	| Occurs when a window's visible icon name changes
|visible_name 		| Occurs when a window's visible name changes
|window_name 		| Occurs when a window's name (WM_NAME) is set
|windowshade 		| Occurs when a window is shaded
|===

+
The window related event handlers are executed within a window context.
Previously PassId was used for this purpose, but now using PassId is not
needed.
+
The monitor_* events do not operate in a window context (as there isn't
one), but react to when a monitor is plugged in (enabled), unplugged
(disabled), focused (focus) or changed (resized/rotated, etc., which
will only be true if the monitor is already active).
+
The echo event is generated whenever Fvwm receives an Echo command.
+
Note: The enter_window event is generated when the pointer enters a
window. With the -passid option, that window's id is passed to fvwm. An
enter_window event is generated too when the pointer leaves a window and
moves into the root window. In this case, the id passed is 0.
+
Note: When the shutdown event arrives, FvwmEvent may be killed before it
can trigger the associated action.

*FvwmEvent: Delay 5::
  Specifies that an event-action will only be executed if it occurs at
  least 5 seconds after the previous event. Events that occur during the
  delay period are ignored. The default delay is 0 which disables the Event.

*FvwmEvent: StartDelay delay::
  Specifies that an event-action will only be executed if it occurs at
  least _delay_ seconds after the startup event. Events that occur
  during the delay period are ignored. This option is useful when _fvwm_
  starts and restarts using an audio player. The default delay is 0.

== HISTORY

This module has evolved of _FvwmAudio_, which in term is heavily based
on a similar Fvwm module called _FvwmSound_ by Mark Boyns. _FvwmAudio_
simply took Mark's original program and extended it to make it generic
enough to work with any audio player. Due to different requests to do
specific things on specific events, _FvwmEvent_ took this one step
further and now calls any _fvwm_ function. If _fvwm_'s Exec function
is used, any external program can be called with any parameter.

== AUTHORS

* 1994  FvwmSound  Mark Boyns       (boyns@sdsu.edu)
* 1994  FvwmAudio  Mark Scott       (mscott@mcd.mot.com)
* 1996  FvwmAudio  Albrecht Kadlec
* 1998  FvwmEvent  Albrecht Kadlec  (albrecht@auto.tuwien.ac.at)
