# Conditional Commands

Conditional commands are commands that are only executed if certain conditions are met. Most conditional commands work on windows, like , or . There is one conditional command, , that works on global conditions unrelated to windows. The syntax of the conditions is described below. For readability, the list of conditions is located at the end of this section.

## Return Codes

All commands in this section (unless specifically stated for the command) also have a return code that can be 1 (if the condition was met) or 0 (if the condition was not met). Some commands may return -1 which means that an error occurred and the return code is useless. The Break command returns -2. Additionally, the return codes of commands run in a complex functions are passed to the invoking complex function. The return code is used by the command. Please refer to the commands' description for examples. The return code can also be accessed through the variable $[cond.rc]. Non conditional commands do not modify the return code of the last conditional command. Important note: return codes are only defined inside functions created with the command and are not inherited by sub functions. To run a command without altering the return code, the command can be used.

## The Ring of Windows

Fvwm stores windows in a ring internally. Think of the focused window as a cursor on the current position in the ring. The command and many other commands search forwards through the ring for a matching window, and searches backwards. The windows in the ring are either ordered by creation time (if the !FPSortWindowlistByFocus, NeverFocus or MouseFocus styles are used) or by the last time they had the focus.

## List of Conditional Commands

## Conditions

The conditions that may be given as an argument to any conditional command are a list of keywords separated by commas, enclosed in parentheses. Unless stated otherwise, conditional commands accept all the conditions listed below. Note that earlier versions of fvwm required the conditions to be separated by whitespace instead of commas and enclosed in brackets instead of parentheses (this is still supported for backward compatibility).

In addition, the conditions may include one or more window names to match to. If more than one window name is given, all of them must match. The window name, icon name, class, and resource are considered when attempting to find a match. Each name may include the wildcards '*' and '?', and may consist of two or more alternatives, separated by the character '|', which acts as an OR operator. (If OR operators are used, they must not be separated by spaces from the names.) Each window name can begin with '!', which prevents command if any of the window name, icon name, class or resource match. However, '!' must not be applied to individual names in a group separated by OR operators; it may only be applied to the beginning of the group, and then it operates on the whole group.

Examples:

     ("Netscape|konqueror|Mozilla*")  99 90

This goes to the next web browser window, no matter which of the three named web browsers is being used.

     ("Mozilla*", "Bookmark*")  99 90

This goes to Mozilla's bookmark manager window, ignoring other Mozilla windows and other browsers' bookmark windows.

     ("XTerm|rxvt", !console)

This iconifies all the xterm and rxvt windows on the current page, except that the one named "console" (with the -name option to xterm) is excluded.

     (!"|*|")
     (!, !*, !)

These two commands are equivalent; either one raises the next window which is not one of the named fvwm modules.

Any condition can be negated by using a an exclamation mark ('!') directly in front of its name.

AcceptsFocus, AnyScreen, CirculateHit, CirculateHitIcon, CirculateHitShaded, Closable, CurrentDesk, CurrentGlobalPage, CurrentGlobalPageAnyDesk, CurrentPage, CurrentPageAnyDesk, CurrentScreen, Desk, FixedPosition, FixedSize, Focused, HasHandles, HasPointer, Iconic, Iconifiable, Layer [n], Maximizable, Maximized, Overlapped, PlacedByButton n, PlacedByButton3, PlacedByFvwm, Raised, Shaded, State n, Sticky, StickyAcrossDesks, StickyAcrossPages, StickyIcon, StickyAcrossDesksIcon, StickyAcrossPagesIcon, Transient, Visible.

The AcceptsFocus condition excludes all windows that do not want the input focus (the application has set the "Input hints" for the window to False) and do not use the Lenience option of the Style command. Also, all windows using the NeverFocus style are ignored. Note: !Lenience is equivalent to the deprecated option NoLenience.

With the AnyScreen condition used together with any of the Current... conditions, windows that do not intersect the Xinerama screen containing the mouse pointer are considered for a match too. For example:

    # Focus next window on current page,
    # regardless of Xinerama screen
     (CurrentPage, AnyScreen)

The CirculateHit and CirculateHitIcon options override the CirculateSkip and CirculateSkipIcon Style attributes for normal or iconic windows. The CirculateHitShaded option overrides the CirculateSkipShaded Style. All three options are turned on by default for the command. They can be turned off by specifying !CirculateHit etc. explicitly. Note: Do not confuse these conditions with the style options of the same name. Specifically,

     foo CirculateSkip
     (foo, CirculateHit) ...

is not the same as

     foo CirculateHit ...
     (foo)

The prior selects windows with the name foo only in the Next command. In the second example, these windows are always matched in all conditional commands.

The Closable condition matches only windows that are allowed to be closed.

The CurrentDesk condition matches only windows that are on the current desk.

The CurrentGlobalPage condition matches only windows that are on the current page of the current desk, regardless of whether Xinerama support is enabled or not. This condition implicitly activates the CurrentDesk condition.

The CurrentGlobalPageAnyDesk condition matches only windows that are on the current page of any desk, regardless of whether Xinerama support is enabled or not.

The CurrentPage condition matches only windows that are on the current page of the current desk. If Xinerama support is enabled, it only matches windows that are at least partially on the Xinerama screen containing the mouse pointer. This condition implicitly activates the CurrentDesk condition.

The CurrentPageAnyDesk and CurrentScreen conditions matches only windows that are on the current page of any desk. If Xinerama support is enabled, they only match windows that are at least partially on the Xinerama screen containing the mouse pointer.

The Screen [n] condition matches only windows which are on the specified Xinerama screen.

The Desk [n] condition matches only windows which are on the specified desk.

The FixedPosition condition excludes all windows that do not have a fixed position, either set through WM hints or the Style option FixedPosition. Example:

     ToggleFixedGeometry
       ToggleFixedGeometry
    + I  (FixedPosition) \
    	 VariablePosition, VariableSize
    + I  (NoMatch)  FixedPosition, FixedSize

The FixedSize condition excludes all windows that do not have a fixed size, either set through WM hints or the Style option FixedSize.

The Focused matches on the window that currently has the keyboard focus. This is not useful for the Current command but can be used with the other conditional commands.

The HasHandles condition excludes all windows that do not have resize handles.

The HasPointer condition excludes all windows that do not contain the pointer.

The Iconic condition matches only iconic windows.

The Iconifiable condition matches only windows that are allowed to be iconified.

The Layer [n] condition matches only windows on the specified layer. The optional argument of the Layer condition defaults to the layer of the focused window. The negation !Layer switches off the Layer condition.

The Maximizable condition matches only windows that are allowed to be maximized.

The Maximized condition matches only maximized windows.

The Fullscreen condition matches only fullscreen windows.

The Overlapped condition matches only windows that are overlapped by other windows on the same layer (or unmanaged windows if the option RaiseOverUnmanaged of the command is used). Note that this condition can be slow if you have many windows or if RaiseOverUnmanaged is used and the connection to the X server is slow.

The PlacedByButton n condition is fulfilled if the last interactive motion of the window (with the command or as ManualPlacement) was ended by pressing mouse button n. Example:

       1 T     A        MoveWindow

     MoveWindow
     MoveWindow
    + C
    + C  (PlacedByButton 5)  off
    + C  (Match)  on 0 100
    + C  (PlacedByButton 4)  on

The PlacedByButton3 condition has the same meaning as PlacedByButton 3. It remains only for backward compatibility.

The PlacedByFvwm condition excludes all windows that have been placed manually or by using the user or program position hint.

The Raised conditions matches only windows that are fully visible on the current viewport and not overlapped by any other window.

The Shaded conditions matches only shaded windows (see command).

The State n or !State n conditions match only windows with the specified integer state set (or unset). See the command for details. The argument may range from 0 to 31.

The Sticky, StickyAcrossDesks and StickyAcrossPages match only windows that are currently sticky, sticky across all desks or sticky across all pages. Please refer to the options with the same name and the commands , and for details.

The StickyIcon, StickyAcrossDesksIcon and StickyAcrossPagesIcon match only windows that become sticky, sticky across all desks or sticky across all pages when they are in iconified state.

The Transient condition matches only windows that have the "transient" property set by the application. This it usually the case for application popup menus and dialogs. The module can be used to find out whether a specific window is transient.

The Visible condition matches only windows that are at least partially visible on the current viewport and not completely overlapped by other windows.