1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!-- $Id: expansion.xml,v 1.3 2008/10/04 22:35:21 domivogt Exp $ -->
3 <!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
4 "../docbook-xml/docbookx.dtd"
6 <!ENTITY % myents SYSTEM "../fvwm.ent" >
11 <section id='command_expansion'>
12 <title>Command Expansion</title>
14 <para>Whenever an fvwm command line is executed, fvwm performs parameter
15 expansion. A parameter is a '$' followed by a word enclosed in
16 brackets ($[...]) or a single special character. If fvwm
17 encounters an unquoted parameter on the command line it expands it
18 to a string indicated by the parameter name. Unknown parameters
19 are left untouched. Parameter expansion is performed before
20 quoting. To get a literal '$' use "$$".</para>
22 <para>If a command is prefixed with a '-' parameter expansion isn't
23 performed. This applies to the command immediately following the '-',
24 in which the expansion normally would have taken place. When uesed
25 together with other prefix commands it must be added before the other
31 <fvwmref cmd="Pick"/> -<fvwmref cmd="Exec"/> exec xmessage '$[w.name]'
34 <para>opens an xmessage dialog with "$[w.name]" unexpanded.</para>
38 <para>The longer variables may contain additional variables inside the
39 name, which are expanded before the outer variable.</para>
41 <para>In earlier versions of fvwm, some single letter variables were
42 supported. It is deprecated now, since they cause a number of
43 problems. You should use the longer substitutes instead.</para>
48 # Print the current desk number, horizontal page number
49 # and the window's class (unexpanded here, no window).
50 <fvwmref cmd="Echo"/> $[desk.n] $[page.nx] $[w.class]
54 <para>Note: If the command is called outside a window context, it
55 prints "$[w.class]" instead of the class name. It is usually not
56 enough to have the pointer over a window to have a context window.
57 To force using the window with the focus, the
58 <fvwmref cmd="Current"/>
59 command can be used:</para>
62 <fvwmref cmd="Current"/> <fvwmref cmd="Echo"/> $[desk.n] $[page.nx] $[w.class]
65 <para>The parameters known by fvwm are:</para>
67 <variablelist remap='TP'>
70 <listitem><para>A literal '$'.</para></listitem>
76 The absolute directory of the currently Read file. Intended for
77 creating relative and relocatable configuration trees. If used
78 outside of any read file, the returned value is '.'.
86 The positional parameters given to a complex function (a function
87 that has been defined with the
88 <fvwmref cmd="AddToFunc"/>
89 command). "$0" is replaced with the first parameter, "$1" with
90 the second parameter and so on. If the corresponding parameter is
91 undefined, the "$..." is deleted from the command line.
99 All positional parameters given to a complex function. This
100 includes parameters that follow after "$9".
105 <term>$[<replaceable>n</replaceable>]</term>
108 The <replaceable>n</replaceable>:th
109 positional parameter given to a complex function, counting from 0.
110 If the corresponding parameter is undefined, the
111 "$[<replaceable>n</replaceable>]" is deleted
112 from the command line. The parameter is expanded unquoted.
117 <term>$[<replaceable>n</replaceable>-<replaceable>m</replaceable>]</term>
120 The positional parameters given to a complex function, starting
121 with parameter <replaceable>n</replaceable> and ending with parameter
122 <replaceable>m</replaceable>.
123 If all the corresponding parameters are undefined, the "$[...]" is
124 deleted from the command line. If only some of the parameters are
125 defined, all defined parameters are expanded, and the remaining
126 silently ignored. All parameters are expanded unquoted.
131 <term>$[<replaceable>n</replaceable>-]</term>
134 All the positional parameters given to a complex function,
135 starting with parameter <replaceable>n</replaceable>.
136 If all the corresponding parameters are undefined, the "$[...]" is
137 deleted from the command line. All parameters are expanded
146 All the positional parameters given to a complex function. This is
152 <term>$[version.num]</term>
154 <para>The version number, like "2.6.0".</para>
158 <term>$[version.info]</term>
161 The version info, like " (from cvs)", empty for the official releases.
166 <term>$[version.line]</term>
169 The first line printed by the --version command line option.
174 <term>$[vp.x] $[vp.y] $[vp.width] $[vp.height]</term>
177 Either coordinate or the width or height of the current viewport.
182 <term>$[desk.n]</term>
183 <listitem><para>The current desk number.</para></listitem>
186 <term>$[desk.name<n>]</term>
189 These parameters are replaced with the name of the desktop
190 number <n> that is defined with the
191 <fvwmref cmd="DesktopName"/>
192 command. If no name is defined, then the default name is returned.
197 <term>$[desk.width] $[desk.height]</term>
200 The width or height of the whole desktop, i.e. the width or height
201 multiplied by the number of pages in x or y direction.
206 <term>$[desk.pagesx] $[desk.pagesy]</term>
209 The number of total pages in a desk in x or y direction.
210 This is the same as the values set by
211 <fvwmref cmd="DesktopSize"/>.
216 <term>$[page.nx] $[page.ny]</term>
219 The current page numbers, by X and Y axes, starting from 0.
220 <emphasis remap='I'>page</emphasis> is equivalent to
221 <emphasis remap='I'>area</emphasis> in the
222 <acronym>GNOME</acronym> terminology.
230 The window-id (expressed in hex, e.g. 0x10023c) of the window the
231 command was called for or "$[w.id]" if no window is associated
238 $[w.name] $[w.iconname] $[w.class] $[w.resource]
239 $[w.visiblename] $[w.iconfile] $[w.miniiconfile]
240 $[w.iconfile.svgopts] $[w.miniiconfile.svgopts]
244 The window's name, icon name, resource class and resource name,
245 visible name, file name of its icon or mini icon defined with the
246 <fvwmref cmd="Style" opt="Icon"/> or
247 <fvwmref cmd="Style" opt="MiniIcon"/>
248 style (including the full path if the file was found on disk),
249 and (if fvwm is compiled with <acronym>SVG</acronym> support)
250 the icon or mini icon svg rendering options (including the
251 leading colon), or unexpanded "$[w.<attribute>]" string
252 if no window is associated with the command.
255 Note, the first 5 variables may include any kind of characters, so
256 these variables are quoted. It means that the value is surrounded
257 by single quote characters and any contained single quote is
258 prefixed with a backslash. This guarantees that commands like:
260 <programlisting><fvwmref cmd="Style"/> $[w.resource] <fvwmref cmd="Style" opt="Icon"/> norm/network.png</programlisting>
262 work correctly, regardless of any special symbols the value may
263 contain, like spaces and different kinds of quotes.
266 In the case of the window's visible name, this is the value returned
267 from the literal title of the window shown in the titlebar. Typically
268 this will be the same as $[w.name] once expanded, although
269 in the case of using <fvwmref cmd="Style" opt="IndexedWindowName"/> then
270 this is more useful a distinction, and allows for referencing the
271 specific window by its visible name for inclusion in things like
272 <fvwmref cmd="Style"/> commands.
277 <term>$[w.x] $[w.y] $[w.width] $[w.height]</term>
280 Either coordinate or the width or height of the current window if
281 it is not iconified. If no window is associated with the command
282 or the window is iconified, the string is left as is.
287 <term>$[w.desk]</term>
290 The number of the desk on which the window is shown. If the
291 window is sticky the current desk number is used.
296 <term>$[w.layer]</term>
297 <listitem><para>The layer of the window.</para></listitem>
300 <term>$[cw.x] $[cw.y] $[cw.width] $[cw.height]</term>
303 These work like $[w....] but return the geometry of the client
304 part of the window. In other words: the border and title of the
305 window is not taken into account.
311 $[i.x], $[it.x], $[ip.x]
312 $[i.y], $[it.y], $[ip.y]
313 $[i.width], $[it.width], $[ip.width]
314 $[i.height], $[it.height], $[ip.height]
318 These work like $[w....] but return the geometry of the icon
319 ($[i....]), the icon title ($[it....]) or the icon picture
325 <term>$[pointer.x] $[pointer.y]</term>
328 These return the position of the pointer on the screen. If the
329 pointer is not on the screen, these variables are not expanded.
334 <term>$[pointer.wx] $[pointer.wy]</term>
337 These return the position of the pointer in the selected window. If
338 the pointer is not on the screen, the window is iconified
339 or no window is selected, these variables are not expanded.
344 <term>$[pointer.cx] $[pointer.cy]</term>
347 These return the position of the pointer in the client portion of
348 the selected window. If the pointer is not on the screen, the
349 window is shaded or iconified or no window is selected, these
350 variables are not expanded.
355 <term>$[screen]</term>
358 The screen number fvwm is running on. Useful for setups with
367 $[hilight.cs<n>]
368 $[shadow.cs<n>]
372 These parameters are replaced with the name of the foreground
373 (fg), background (bg), hilight (hilight) or shadow (shadow) color
374 that is defined in colorset <n> (replace <n> with zero
375 or a positive integer). For example "$[fg.cs3]" is expanded to the
376 name of the foreground color of colorset 3 (in rgb:rrrr/gggg/bbbb
377 form). Please refer to the
378 <fvwmref sect="colorsets" opt="colorsets" name="Colorsets"/>
379 section for details about colorsets.
384 <term>$[schedule.last]</term>
387 This is replaced by the id of the last command that was
388 scheduled with the <fvwmref cmd="Schedule"/> command, even if
389 this command was already executed.
394 <term>$[schedule.next]</term>
397 This is replaced by the id the next command used with
398 <fvwmref cmd="Schedule"/> will get (unless a different id is
399 specified explicitly).
404 <term>$[cond.rc]</term>
407 The return code of the last conditional command. This
408 variable is only valid inside a function and can not be used
409 in a conditional command. Please refer to the section
410 <fvwmref sect="conditionalCommands" opt="conditional_commands"
411 name="Conditional Commands"/> in the command list.
416 <term>$[func.context]</term>
419 The context character of the running command as used in the
420 <fvwmref cmd="Mouse"/>,
421 <fvwmref cmd="Key"/> or
422 <fvwmref cmd="PointerKey"/>
423 command. This is useful for example with:
424 <programlisting><fvwmref cmd="Mouse"/> 3 FS N <fvwmref cmd="WindowShade"/> $$[func.context]</programlisting>
429 <term>$[gt.<replaceable>str</replaceable>]</term>
432 return the translation of
433 <replaceable>str</replaceable> by looking in the current
434 locale catalogs. If no translation is found
435 <replaceable>str</replaceable> is returned as is. See the
436 <fvwmref cmd="LocalePath"/> command.
444 If the string within the braces is neither of the above, fvwm
445 tries to find an environment variable with this name and replaces
446 its value if one is found (e.g. "$[PAGER]" could be replaced by
447 "more"). Otherwise the string is left as is.
454 <para>Some examples can be found in the description of the
455 <fvwmref cmd="AddToFunc"/>