Fvwm − Fvwm module interface for Tcl |
package require Fvwm fvwm::send command ?windowid? fvwm::bind event ?script? fvwm::getConfig varname ?globPattern? fvwm::getWindowList varname fvwm::setMask list fvwm::iconPath name ?option? |
Fvwm package is a Tcl-only package which provides a way to build fvwm(1) modules on Tcl/Tk. Upon package initialization it checks if script is invoked as fvwm module and set ups pipes to communicate with fvwm. If script doesn’t started as fvwm module, package initialization fails. Package provides procedures to set commands to fvwm and obtain information from it. It provides procedures to parse fvwm WindowList and ConfigInfo messages and way to handle messages sended by fvwm just like Tk events. Upon initialization Fvwm package removes all fvwm-specific information from global argv variable and changes argc accordingly. This information can be accessed via package variables. |
Context |
Contain information about context in which module is called. It can be one of following strings: |
NO_CONTEXT, WINDOW, TITLE, ICON, ROOT, FRAME, SIDEBAR, LEFT1 - LEFT5, RIGHT1 - RIGHT5 which corresponds with parts of window decorations, provided by fvwm |
WindowId |
Integer (decimal) identifier of window, in whose context script was called |
configFile |
Name of fvwm configuration file (probably useless for fvwm 2.0, because configuration info could be requested from fvwm itself. |
send command ?windowId? |
sends a command to fvwm. Command is a string exactly as it appears in .fvwmrc file. Command may be optionally followed by window id, in this case it can be applied to given window. |
setMask list |
Instructs fvwm to send only certain events to this script. List should contain list of event names (see EVENTS below) |
bind event ?script? |
binds a script with specific fvwm event (see EVENTS below) Script will be executed in global namespace appended by list of event arguments. If script is omitted, current script would be returned. Specifying empty string disables processing of given event. |
getConfig varname ?globPattern? |
Requests configuration information from fvwm and stores it in the array varname. Glob pattern allows to restrict configuration to lines matching pattern. |
Global configuration lines such as PixmapPath would be always returned, but module-specific lines (those which start from ‘*’), would be returned only if they (with ‘*’ stripped off) match given pattern. First word in line (without ‘*’) would be used as array index. If multiple lines have same first word, they would be concatenated into Tcl list. Entries which are lists of directories (IconPath, PixmapPath) are converted to Tcl list too. |
getWindowList varname |
Requests information about current desktop state and stores it in the given array variable. This array would have indices: |
Desk |
Number of current desk |
Page |
list of four coordinates of current page |
Focus |
containing Id of toplevel window. |
DefaultIcon |
name of default icon (used for windows which have no icon defined) windowId,frame for each window there is list of following values: windowId of window frame, X of frame, Y of frame, width of frame, height of frame, height of title, border width, |
windowId,desk |
number of desktop, |
windowId,flags |
window flags field |
windowId,base |
Offset of window base coordinates from top-left frame corner |
windowId,grid |
resize width increment, resize height increment, |
windowId,min |
minimum width, minimum height. |
windowId,max |
maximum width, maximum height. |
windowId,iconIds |
icon label window id (or 0), icon pixmap window id (or 0), |
windowId,gravitywindow |
gravity, string, as defined in /usr/X11R6/include/X11/X.h |
windowId,title |
Title of window |
windowId,iconName |
Title of icon for this window |
windowId,resource |
Resource name for this window |
windowId,class |
Resource class for this window |
windowId,icon |
Name of xpm file which is used as icon for this window |
windowId,miniIcon |
Name of xpm file which is used as title icon (fvwm-95 only). |
iconPath filename ?option? |
Searches for given filename in fvwm pixmap or icon path and returns full pathname of it if found. I don’t like an idea to return Tcl image because there is two Tcl extension which can create Xpm images - Img and Tix and I don’t know which you’ll prefer. |
option can be either -pixmap or -icon which would cause PixmapPath or IconPath to be searched. Defaults to PixmapPath. |
Fvwm events are described in file docs/modules.tex in fvwm distribution. If you are seriously planning to develop fvwm module, you should read it anyway. Note that event names in tcl Fvwm package differs in capitalization from C constants, defined in fvwm’s module.h. List of names is shown below. When event handler is called it is appended by long list of arguments. First argument passed is always event name, thus allowing you to use same handlers for several event types. All other fields are all field from fvwm packet body, even they are appear completely useless. Refer to modules.tex for description of this fields For convinience we would note that if event is related to particular window, its ID is passed as first argument, and if event have text message associated with it, it is always fourth (don’t counting event name). There is one additional event type DeadPipe, which occurs if eof on pipe is encountered. This event have default handler, which exits from script. It can be redefined to perform applicaton cleanup. Event of type Error have default handler, which raises Tcl error with same message as original event. This error is raised from after idle handler to avoid closing pipe, which is default Tcl behavoir in case of unhandled errors in fileevent scripts. |
FVWM 2.0.43 events |
NewPage NewDesk AddWindow RaiseWindow LowerWindow ConfigureWindow FocusChange DestroyWindow Iconify Deiconify WindowName IconName ResClass ResName End_WindowList IconLocation Map Error ConfigInfo End_ConfigInfo IconFile DefaultIcon String |
FVWM-95 only |
FunctionEnd MiniIcon ScrollRegion |
Dummy event, generated by package itself |
DeadPipe |
fvwm(1), docs/modules.tex in fvwm distribution |
getWindowList doesn’t properly handle pixel color values, returned by fvwm. Parsing event args should be better (may be keyed lists), especially for AddWindow and ConfigureWindow. There could be problems with wrong capitalization in fvwm config file, because getConfig and iconPath work in case-sensitive manner, and fvwm seems to be case-insensitive. |
Victor Wagner <vitus@ice.ru> |