fvwm 条件命令

Conditional Commands


Conditional commands are commands that are only executed if certain conditions are met. Most conditional commands work on windows, like Next, ThisWindow or All. There is one conditional command, Test, 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.


31.11.1. 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 TestRc 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 AddToFunc command and are not inherited by sub functions. To run a command without altering the return code, the KeepRc command can be used.


31.11.2. 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 Next command and many other commands search forwards through the ring for a matching window, and Prev 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.


31.11.3. List of Conditional Commands


31.11.3.1. All


All [options] [(conditions)] command


Execute command on all windows meeting the conditions. It returns 1 if any window matches the condition and 0 otherwise. The execution starts at the top of the window ring and continues towards the bottom. The options can be any combination of Reverse and UseStack. If the option Reverse is given the execution order is reversed. The option UseStack makes All use the stacking order instead of the window ring when walking through windows. See the Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


31.11.3.2. Any


Any [(conditions)] command


Performs command if any window which satisfies all conditions exists. The command is run in the context of the root window. See the Conditions section for a list of conditions.


31.11.3.3. Break


Break [levels]


If the break command is used in a function, function execution is terminated immediately. Further commands of the function are not processed. Normally, all nested invocations of complex functions are left. An optional integer number levels may be given to break out of the given number of nested functions and continue execution of a higher level function. The Break command always has the return code -2. Example:


AddToFunc PickWindowRaiseAndDeiconify
+ I Pick
+ I TestRc (Error) Break
+ I Raise
+ I Iconify off
31.11.3.4. Current


Current [(conditions)] command


Performs command on the currently focused window if it satisfies all conditions. See the Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


31.11.3.5. Direction


Direction [FromPointer] direction [(conditions)] command


Performs command (typically Focus) on a window in the given direction which satisfies all conditions. Normally, the center of the currently focused window or the context window in which the command was invoked is taken as the starting point. Lacking such a window, or when the FromPointer option is given, the current position of the pointer is taken as the starting point. The direction may be one of "North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest" and "Center". Which window Direction selects depends on angle and distance between the center points of the windows. Closer windows are considered a better match than those farther away. The Center direction simply selects the window closest to the starting point. Returns -1 if an invalid direction was given. See the Conditions section for a list of conditions.


31.11.3.6. KeepRc


KeepRc command


Runs the command but does not alter the return code of the previous command. Note: KeepRc is treated as a prefix to its command. Expansion of the command line is done as if KeepRc was not there.


31.11.3.7. Next


Next [(conditions)] command


Performs command (typically Focus) on the next window which satisfies all conditions. If the command is running in a window context, it starts looking for a matching window from there. Otherwise it starts at the focused window. See Conditions section for a list of conditions.


31.11.3.8. None


None [(conditions)] command


Performs command if no window which satisfies all conditions exists. The command is run in the context of the root window. Returns 1 if no window matches the conditions and 0 otherwise. See Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


31.11.3.9. NoWindow


NoWindow command


Performs command, but removes the window context if any. This is not really a conditional command, but a prefix that may be useful in menu items that should operate without a window even if such menu is bound to window decorations.


31.11.3.10. Pick


Pick [(conditions)] command


Pick works like Function if invoked in the context of a window. If invoked in the root window, it first asks the user to pick a window and then executes the command in the context of that window. This avoids annoying multiple selections with complex functions. The command is executed only if the given conditions are met. Returns -1 if no window was selected. See Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


31.11.3.11. PointerWindow


PointerWindow [(conditions)] command


Performs command if the window under the pointer satisfies all conditions. Returns -1 if there is no window under the pointer. See Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


31.11.3.12. Prev


Prev [(conditions)] command


Performs command (typically Focus) on the previous window which satisfies all conditions. If the command is running in a window context, it starts looking for a matching window from there. Otherwise it starts at the focused window. See Conditions section for a list of conditions.


31.11.3.13. ScanForWindow


ScanForWindow [FromPointer] dir1 dir2 [(conditions)] command


Performs command (typically Focus) on a window in the given direction which satisfies all conditions. Normally, the center of the currently focused window or the context window in which the command was invoked is taken as the starting point. Lacking such a window, or when the FromPointer option is given, the current position of the pointer is taken as the starting point. The direction dir1 may be one of "North", "NorthEast", "East", "SouthEast", "South", "SouthWest", "West", and "NorthWest". Which window ScanForWindow selects depends first on the position along the primary axis given by dir1. If any windows have the exact same coordinate along the primary axis, the secondary direction is used to order the windows. The direction dir2 may be one of the same set of values as dir1. If dir2 is not perfectly perpendicular to dir1, ScanForWindow returns a failure. When using ScanForWindow repeatedly with the same arguments, it is guaranteed that all windows matching the conditions will eventually be found. If the focus reaches a limit along the primary axis, it will wrap around to the opposite side. Returns -1 if an invalid direction was given. See Conditions section for a list of conditions.


31.11.3.14. Test


Test [(test-conditions)] command


Performs command if all test-conditions are satisfied. The test-conditions are keywords with possible arguments from the list below and are separated by commas or whitespace. They include: Version operator x.y.z, EnvIsSet varname, EnvMatch varname pattern, EdgeHasPointer direction, EdgeIsActive direction, Start, Init, Restart, Exit, Quit, ToRestart, True, False, F, R, W, X and I. A test-condition prefixed with "!" is negated.


The Version operator x.y.z test-condition is fulfilled if the logical condition of the expression is true. Valid operator values are: >=, >, <=, <, == and !=.


Example:


Test (Version >= 2.5.11) Echo 2.5.11 or later.
The EnvIsSet varname test-condition is true if the given environment variable is set. The EnvMatch varname pattern test-condition is true if pattern matches the given environment variable value. The pattern may contain special "*" and "?" chars.


The EdgeHasPointer [direction] test-condition is true if the edge in the given direction currently contains the pointer. The EdgeIsActive [direction] test-condition is true if the edge in the given direction currently is active. An edge is active, and can contain a pointer if either a command is bound to it or edge scroll is available in that direction. The direction may be one of Any, North, Top, Up, West, Left, South, Bottom, Down, Right and East. If no direction is specified Any is assumed.


The Start test-condition is the same as either Init or Restart. It is only true on startup or restart prior and during StartFunction execution. The Exit test-condition is the same as either Quit or ToRestart. It is only valid on shutdown during ExitFunction function execution.


The True and False test-conditions are unconditionally true and false.


Additionally, if a test-condition name is not recognized, the Error return code is set and the command is not executed.


The F file, R file, W file, X file and I file test-conditions test for existence of the given [F]ile (possibly with [R]ead/[W]rite permissions), e[X]ecutable (in $PATH), or the [I]mage (in ImagePath).


Example:


AddToFunc StartFunction I Test (Init) Exec exec xterm


AddToFunc VerifyVersion
+ I Test (Version 2.5.*) Echo 2.5.x detected
+ I TestRc (NoMatch) \
Test (!Version 2.6.*) Echo Future version
+ I TestRc (NoMatch) \
Echo 2.6.x is detected


Test (F $[FVWM_USERDIR]/local-config) Read local-config
Test (X xterm-utf16) Exec exec xterm-utf16
31.11.3.15. TestRc


TestRc [([!]returncode)] command


Performs command if the last conditional command returned the value returncode. Instead of the numeric values 0 (no match), 1 (match), -1 (error), and -2 (break) the symbolic names "NoMatch", "Match", "Error" and "Break" can be used. If no returncode is given, the default 0 is assumed. If the return code is prefixed with '!', the command is executed if returncode does not match the value returned by the conditional command. The TestRc command can only be used inside functions. If the command is another conditional command, the previous return code is replaced by the new one. Example:


AddToFunc ToggleXterm
+ I All (my_xtermwindow) Close
+ I TestRc (NoMatch) Exec xterm -T my_xtermwindow
31.11.3.16. ThisWindow


ThisWindow [(conditions)] command


ThisWindow executes the specified command in the context of the current operand window. If there is no operand window (it is invoked in the root window), the command is ignored. ThisWindow is never interactive. The command is executed only if the given conditions are met. It returns -1 if used outside a window context. See Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying "!CirculateHit" etc. explicitly.


31.11.3.17. WindowId


WindowId [id] [(conditions)] | [root [screen]] command


The WindowId command looks for a specific window id and runs the specified command on it. The second form of syntax retrieves the window id of the root window of the given screen. If no screen is given, the current screen is assumed. The window indicated by id may belong to a window not managed by fvwm or even a window on a different screen. Although most commands can not operate on such windows, there are some exceptions, for example the WarpToWindow command. Returns -1 if no window with the given id exists. See Conditions section for a list of conditions.


This command implies the conditions CirculateHit, CirculateHitIcon and CirculateHitShaded. They can be turned off by specifying !CirculateHit etc. explicitly.


Examples:


WindowId 0x34567890 Raise
WindowId root 1 WarpToWindow 50 50
WindowId $0 (Silly_Popup) Delete
In the past this command was mostly useful for functions used with the WindowList command, or for selective processing of FvwmEvent calls (as in the last example), but currently these handler functions are called within a window context, so this command is not really needed in these cases. Still it may be useful if, for example, the window id should be stored in the environment variable for a further proceeding.


Pick SetEnv BOOKMARKED_WINDOW $[w.id]
WindowId $[BOOKMARKED_WINDOW] WarpToWindow
31.11.4. 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:


Next ("Netscape|konqueror|Mozilla*") WarpToWindow 99 90
This goes to the next web browser window, no matter which of the three named web browsers is being used.


Next ("Mozilla*", "Bookmark*") WarpToWindow 99 90
This goes to Mozilla's bookmark manager window, ignoring other Mozilla windows and other browsers' bookmark windows.


All ("XTerm|rxvt", !console) Iconify
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.


Next (!"FvwmPager|FvwmForm*|FvwmButtons") Raise
Next (!FvwmPager, !FvwmForm*, !FvwmButtons) Raise
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, 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
Next (CurrentPage, AnyScreen) Focus
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 Current 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,


Style foo CirculateSkip
Next (foo, CirculateHit) ...
is not the same as


Style foo CirculateHit ...
Next (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 FixedPosition condition excludes all windows that do not have a fixed position, either set through WM hints or the Style option FixedPosition. Example:


DestroyFunc ToggleFixedGeometry
AddToFunc   ToggleFixedGeometry
+ I Pick (FixedPosition) \
WindowStyle VariablePosition, VariableSize
+ I TestRc (NoMatch) WindowStyle 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 Overlapped condition matches only windows that are overlapped by other windows on the same layer (or unmanaged windows if the option RaiseOverUnmanaged of the BugOpts 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 Move command or as ManualPlacement) was ended by pressing mouse button n. Example:


Mouse   1 T     A       Function MoveWindow


DestroyFunc MoveWindow
AddToFunc MoveWindow
+ C Move
+ C ThisWindow (PlacedByButton 5) WindowShade off
+ C TestRc (Match) Maximize on 0 100
+ C ThisWindow (PlacedByButton 4) WindowShade 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 WindowShade command).


The State n or !State n conditions match only windows with the specified integer state set (or unset). See the State 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 Style options with the same name and the commands Stick, StickAcrossDesks and StickAcrossPages 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 FvwmIdent 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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值