1FvwmScript(1) Fvwm Modules FvwmScript(1)
2
3
4
6 FvwmScript - module to build graphic user interface
7
8
10 FvwmScript must be spawned by Fvwm. It will not work from the command
11 line.
12
13
15 FvwmScript is a module which allows you to build many graphical appli‐
16 cations such as desktop accessories, button panel with pop up menus,
17 modal dialogs... At the startup, FvwmScript reads the file which is
18 specified on the command line. This file contains the script. This
19 script is not included in the configuration file of Fvwm.
20
21 An FvwmScript script is fully controllable by using the keyboard.
22 (Shift)-Tab circulates around the widgets, Return simulates a mouse
23 click, the arrows move the cursor or change the values of the widget
24 and Escape "cancels" for Menu and PopupMenu.
25
26
28 FvwmScript can be invoked by inserting the line `Module FvwmScript
29 name_of_script' in the .fvwm2rc file. The file "name_of_script" can
30 start with a slash, in which case, it's a fully qualified path, and the
31 file is read. If "name_of_script" does not start with a slash, Fvwm‐
32 Script will look in a few different places. If the .fvwm2rc con‐
33 tained the command line `*FvwmScript: Path
34 path_of_the_script_directory', FvwmScript will try that directory. If
35 that doesn't work, FvwmScript tries the system configuration directory
36 and the user configuration directory as described under the "Read" com‐
37 mand in the fvwm man page.
38
39 The command to start FvwmScript can be placed on a line by itself, if
40 FvwmScript is to be spawned during fvwm's initialization, or can be
41 bound to a menu or mouse button or keystroke to invoke it later.
42
43
45 The following commands can be used in the config file (see fvwm(1),
46 section MODULE COMMANDS for details). They are used only if the corre‐
47 sponding script commands are not used in the script.
48
49
50 *FvwmScript: DefaultFont font
51 Specifies the default font to be used. If not specified with
52 this command or in the script with the Font command, fixed font
53 is assumed.
54
55
56 *FvwmScript: DefaultFore color
57 Specifies the default foreground color to be used. If not speci‐
58 fied with this command or in the script with the ForeColor com‐
59 mand, black is used.
60
61
62 *FvwmScript: DefaultBack color
63 Specifies the default background color to be used. If not speci‐
64 fied with this command or in the script with the BackColor com‐
65 mand, grey85 is used.
66
67
68 *FvwmScript: DefaultHilight color
69 Specifies the default hilight color to be used. If not specified
70 with this command or in the script with the HilightColor com‐
71 mand, grey100 is used.
72
73
74 *FvwmScript: DefaultShadow color
75 Specifies the default shadow color to be used. If not specified
76 with this command or in the script with the ShadowColor command,
77 grey55 is used.
78
79
80 *FvwmScript: DefaultColorset colorset
81 Tells the module to use colorset colorset as the default col‐
82 orset.
83
84
86 FvwmScript uses a particular programming language. A script is composed
87 of five parts. Heading contains general characteristics of the window
88 and default properties for all widgets. The second part contains
89 instructions whom are executed at the startup of the script. The third
90 part contains periodic tasks which are executed every second. The
91 fourth part contains instructions which are executed at exit. And the
92 last part contains the description of widgets. A widget consists of
93 eleven types of items: text labels, single-line text inputs, radio but‐
94 tons, checkbox, push buttons, horizontal and vertical scrollbars, rec‐
95 tangles, pop up menus, swallowexecs and mini scrollbars.
96
97
99 The syntax is as follows:
100
101
102 WindowTitle string
103 This option sets the window title.
104
105
106 WindowSize width height
107 This option sets window size. width and height are numerical
108 value.
109
110
111 WindowPosition x y
112 This option sets window position. x and y are numerical value.
113
114
115 ForeColor {color}
116 This option sets the default foreground color for all widgets.
117
118
119 BackColor {color}
120 This option sets the default background color for all widgets.
121
122
123 HilightColor {color}
124 This option sets the default hilight color for all widgets.
125
126
127 ShadowColor {color}
128 This option sets the default shadow color for all widgets.
129
130
131 Colorset {n}
132 This option sets the default colorset for all widgets.
133
134
135 Font {font}
136 This option sets the default font for all widgets.
137
138
139 UseGettext [locale_path]
140 Enable the use of the gettext mechanism which is used by the
141 WindowLocaleTitle, LocaleTitle, ChangeLocaleTitle instructions
142 and the Gettext function. If no argument is given, the default
143 FvwmScript locale catalog is used. This catalog is under the
144 locale fvwm installation directory and the text domain is Fvwm‐
145 Script (install_prefix/share/locale/*/LC_MESSAGES/Fvwm‐
146 Script.mo). You can reset this catalog or add some catalogs
147 exactly in the same way than with the LocalePath fvwm command
148 (see the fvwm manual page). This instruction should be placed
149 before the WindowLocaleTitle instruction.
150
151
152 WindowLocaleTitle string
153 This option sets the window title, but use the locale catalog(s)
154 defined with UseGettext.
155
156
158 This part contains instructions which will be executed at the startup.
159 For example:
160 Init
161 Begin
162 Do "Exec cat tada.voc > /dev/dsp"
163 WarpPointer 1
164 Set $ToDo=Restart
165 End
166 These instructions are used to play a sound, move the pointer to widget
167 1 and to initialize $ToDo to "Restart" at every startup.
168
169
171 This part of the script contains instructions that are executed every
172 second. For example:
173 PeriodicTasks
174 Begin
175 If (RemainderOfDiv (GetTime) 10)==0 Then
176 Do {Exec xcalc}
177 End
178 This example shows how to launch xcalc every 10 seconds.
179
180
182 This part of the script contains instructions that are executed when
183 the script exits (after the Quit instruction or if you close the window
184 with the Close, Delete or Destroy fvwm command). For Example
185 QuitFunc
186 Begin
187 Do {Echo bye, bye}
188 End
189 Be aware that if you used the KillModule fvwm command to close the
190 script, some instructions or functions which rely on the existence of a
191 communication link between the script and fvwm will not be executed
192 (for example the Do command). To smoothly kill a script with an fvwm
193 command see the COMMANDS section.
194
195
197 The second part of the script contains the description for every widget
198 in the script. Each widget description has two parts. The first part
199 describes initial properties, the second part contains instructions
200 that are executed when the widget receives messages. All widgets can
201 send and receive messages. All messages are identified by a number.
202 The message "UserAction" is sent to a widget when the user operates the
203 widget. The syntax for the first part is:
204 Widget id # A number between 1 and 999 inclusive
205 Property
206 Type string
207 Size width height
208 Position x y
209 Title { string }
210 Value int
211 MaxValue int
212 MinValue int
213 Font string
214 ForeColor { color }
215 BackColor { color }
216 HilightColor { color }
217 ShadowColor { color }
218 Colorset int
219 Flags flagsOpt
220 The flagsOpt option to Flags is a space separated list containing one
221 or more of the keywords Hidden, NoReliefString, NoFocus, Left / Cen‐
222 ter / Right. Hidden is used to specify if the widget is hidden at
223 startup. NoReliefString specifies if strings are drawn with relief or
224 not. NoFocus specifies if the widget can get the keyboard focus or
225 not. By default all widgets take focus, except Rectangle, HDipstick
226 and VDipstick which cannot. Moreover, the NoFocus widgets are skipped
227 when you circulate around the widgets with the (Shift-)Tab short cut.
228 Left / Center / Right specifies the text position. These apply only to
229 ItemDraw, List, Menu, PopupMenu and PushButton. The default is Center
230 for ItemDraw and PushButton and Left for the other widgets.
231
232 LocaleTitle can be used in place of Title, for using the locale cata‐
233 log(s) defined with UseGettext.
234
235 The position of every widget must be specified.
236
237 The syntax for the second part is:
238 Main
239 Case message of
240 SingleClic:
241 Begin
242 # list of instructions which will be
243 # executed when widget receives
244 # message "SingleClic". This message is
245 # generated by the user.
246 End
247 1 :
248 Begin
249 # list of instructions which will be
250 # executed when widget receives
251 # message 1
252 End
253 End
254
255
257 There is fifteen types of widgets.
258
259
260 CheckBox: Display check box with a string.
261
262 Title: title of the check box.
263
264 Value: if Value is equal to 1, the box is checked else it is
265 not.
266
267 The Size property is ignored.
268
269
270 HDipstick: Display a horizontal dipstick.
271 This widget can be used to display disk usage.
272
273 Value: specify the current value of the dipstick.
274
275 MinValue: specify the minimum value of the dipstick.
276
277 MaxValue: specify the maximum value of the dipstick.
278
279 A minimum size of 30x11 is imposed.
280
281
282 HScrollBar: Display an horizontal scrollbar.
283
284 Value: position of the thumb.
285
286 MaxValue: upper limit of Value.
287
288 MinValue: lower limit of Value.
289
290 The height property is ignored and a minimum width is imposed.
291 The width should be at least the range plus 37 if all values are
292 to be selectable e.g. a min of 0 and max of 10 has a range of
293 11 and therefore should have a minimum width of 48.
294
295
296 ItemDraw: Display an icon and/or a string.
297
298 Title: string to display.
299
300 Icon: icon to display.
301
302 MaxValue: x coordinate of the cursor.
303
304 MinValue: y coordinate of the cursor.
305
306 The size is made large enough to contain the title and/or the
307 icon.
308
309
310 List: Display a list.
311 List lets user to choose between various options.
312
313 Value: specify which option is selected.
314
315 MinValue: First visible option.
316
317 Title: title contains options displayed in the list. The syntax
318 is the following: {Option 1|Option 2|...|Option N}. All menus
319 are displayed at the top of window.
320
321 A minimum height of three items is imposed and the width is made
322 to be at least 108.
323
324
325 Menu: Display a menu whom lets user to choose a option.
326 Items of type Menu are layed out from left to right along the
327 top of the window. The size and position properties are ignored.
328
329 Value: specify which option is selected.
330
331 Title: title contains options displayed in the menu. The syntax
332 is the following: {Option 1|Option 2|...|Option N}.
333
334
335 MiniScroll: Display a very small vertical scrollbar.
336
337 Value: position of the thumb.
338
339 MaxValue: upper limit of Value.
340
341 MinValue: lower limit of Value.
342
343 The size is set to 19x34.
344
345
346 PopupMenu: Display a pop up menu.
347
348 Value: specify what option is selected.
349
350 Title: the title has the following syntax: {Option 1|Option
351 2|...|Option N}."Option 1|Option 2|...|Option N" is the pop up
352 menu which is displayed when pressing mouse button.
353
354 The size property is ignored.
355
356
357 PushButton: Display push button with an icon and/or a string.
358
359 Title: this string has the following syntax {Title of the but‐
360 ton|Option 1|Option 2|Option3|...|Option N}. "Option 1|Option
361 2|...|Option N" is the pop up menu which is displayed when
362 pressing the right button.
363
364 Icon: icon to display.
365
366 The button is made large enough to fit the icon and or label.
367
368
369 RadioButton: Display radio button with a string.
370
371 Title: title of the radio button.
372
373 Value: if Value is equal to 1, the box is checked else it is
374 not.
375
376 The size property is ignored
377
378
379 Rectangle: Display a rectangle.
380 This type of widget can be used to decorate window.
381
382
383 SwallowExec
384 This type of widget causes FvwmScript to spawn an process, and
385 capture the first window whose name or resource is equal to
386 Title, and display it in the script window.
387
388 Title: specify the window name which be captured and displayed
389 in the script window.
390
391 SwallowExec: specify the command line to execute to spawn the
392 process. Modules can also be swallowed.
393
394 Value: specify the looking of the border. Possible value: -1, 0,
395 1.
396
397 The size is made to be at least 30x30
398
399
400 TextField: Display a text input field.
401 The text input field can be used to edit a single-line string.
402
403 Title: content of text field.
404
405 Value: position of the insert point.
406
407 MinValue: position of the end of the selection.
408
409 MaxValue: first visible character of the title
410
411 The height property is ignored, the width is made to be at least
412 40 pixels wider than the initial contents.
413
414
415 VDipstick: Display a vertical dipstick.
416
417 Value: specify the current value of the dipstick.
418
419 MinValue: specify the minimum value of the dipstick.
420
421 MaxValue: specify the maximum value of the dipstick.
422
423 The size is made to be at least 11x30.
424
425
426 VScrollBar: Display a vertical scrollbar.
427
428 Value: position of the thumb.
429
430 MaxValue: upper limit of Value.
431
432 MinValue: lower limit of Value.
433
434 The width property is ignored and a minimum height is imposed.
435 The height should be at least the range plus 37 if all values
436 are to be selectable e.g. a min of 0 and max of 10 has a range
437 of 11 and therefore should have a minimum height of 48.
438
439
441 Here is the description of all instructions.
442
443
444 HideWidget id : hide the widget numbered id.
445
446
447 ShowWidget id: show the widget numbered id.
448
449
450 ChangeValue id1 id2
451 Set the value of the widget numbered id1 to id2.
452
453
454 ChangeMaxValue id1 id2
455 Set the maximum value of the widget numbered id1 to id2.
456
457
458 ChangeMinValue id1 id2
459 Set the minimum value of the widget numbered id1 to id2.
460
461
462 ChangeTitle id1 id2
463 Set the title of the widget numbered id1 to id2.
464
465
466 ChangeWindowTitle string
467 Set the title of the window to string.
468
469
470 ChangeWindowTitleFromArg numarg
471 Set the title of the window to the value of the numarg-th script
472 argument.
473
474
475 ChangeLocaleTitle id1 id2
476 As ChangeTitle but use the locale catalog(s) defined with
477 UseGettext.
478
479
480 ChangeIcon id1 id2
481 Set the icon of the widget numbered id1 to id2.
482
483
484 ChangeForeColor id1 {color}
485 Set the foreground color of the widget numbered id1 to {color}.
486
487
488 ChangeBackColor id1 {color}
489 Set the background color of the widget numbered id1 to {color}.
490
491
492 ChangeColorSet id1 id2
493 Set the colorset of the widget numbered id1 to id2. Specifying
494 widget 0 sets the main window colorset.
495
496
497 ChangePosition id1 x y
498 Move the widget numbered id1 to position (x,y).
499
500
501 ChangeSize id1 width height
502 Set the size of the widget numbered id1 to (width,height).
503
504
505 ChangeFont id1 newfont
506 Set the font of the widget numbered id1 to newfont.
507
508
509 WarpPointer id
510 Warp the mouse pointer into the widget numbered id.
511
512
513 WriteToFile filename {str1} {str2} etc
514 Write to the file filename the string which is the concatenation
515 of all arguments str1, str2, etc.
516
517
518 Do {command args}
519 Execute the fvwm command inside the Do block. Any fvwm command
520 as described in the fvwm2 man page can be used. Commands are
521 sent from this module to the fvwm main program for processing.
522 The length of the command and arguments can not exceed 988 char‐
523 acters.
524
525
526 Set $var={str1} {str2} etc
527 Concatenate all arguments to a string and set the variable $var
528 to this string.
529
530
531 Quit: quit the program.
532
533
534 SendSignal id1 id2
535 Send a message numbered id2 to widget id1.
536
537
538 SendToScript id_script {str11} {str2} etc
539 Send a message to the script identified by id_script. The mes‐
540 sage is the concatenation of str1, str2...
541
542
543 Key Keyname Modifier id sig str1 str2 etc
544 Binds a keyboard key to the instruction
545
546 SendSignal id sig
547
548 and sets the "last string" to the concatenation of str1, str2...
549 (see the LastString function). The Keyname and Modifiers fields
550 are defined as in the fvwm Key command.
551
552
554 Most of commands use arguments. There are two kinds of arguments: num‐
555 bers and strings. A numerical argument is a value which is between
556 -32000 and +32000. A string is always surrounded with braces. Variables
557 always begin with the character "$" and can contain both numbers and
558 strings.
559
560
562 All functions use arguments. Functions can return both a string and a
563 number. The syntax is:
564 (function argument1 argument2 etc)
565 Here is the complete list of arguments:
566
567
568 (GetTitle id)
569 Return the title of the widget numbered id.
570
571
572 (GetValue id)
573 Return the current value of the widget numbered id.
574
575
576 (GetMinValue id)
577 Return the current Min value of the widget numbered id.
578
579
580 (GetMaxValue id)
581 Return the current Max value of the widget numbered id.
582
583
584 (GetFore id)
585 Return the current RGB foreground value of the widget numbered
586 id in the hex format RRGGBB.
587
588
589 (GetBack id)
590 Return the current RGB background value of the widget numbered
591 id in the hex format RRGGBB.
592
593
594 (GetHilight id)
595 Return the current RGB hilight value of the widget numbered id
596 in the hex format RRGGBB.
597
598
599 (GetShadow id)
600 Return the current RGB shadow value of the widget numbered id in
601 the hex format RRGGBB.
602
603
604 (GetOutput {str} int1 int2)
605 Executes the command str, gets the standard output and returns
606 the word which is in the line int1 and in the position int2. If
607 int2 is equal to -1, GetOutput returns the complete line.
608
609
610 (NumToHex int)
611 Return the hexadecimal value of int.
612
613
614 (HexToNum {str})
615 Return the decimal value of str, str must be an hexadecimal
616 value.
617
618
619 (Add int1 int2)
620 Return the result of (int1+int2).
621
622
623 (Mult int1 int2)
624 Return the result of (int1*int2).
625
626
627 (Div int1 int2)
628 Return the result of (int1/int2).
629
630
631 (StrCopy {str} int1 int2)
632 Return the string whom is between position int1 and int2. For
633 example, (StrCopy {Hello} 1 2) returns {He}
634
635
636 (LaunchScript {str})
637 This function launches the script named str and returns an iden‐
638 tification number. This number is necessary to use the func‐
639 tions SendToScript and ReceiveFromScript. The string str con‐
640 tains the script name and some arguments.
641
642
643 (GetScriptArgument {int})
644 This function returns the argument script used in the function
645 LaunchScript. If int is equal to zero, GetScriptArgument
646 returns the name of the script.
647
648
649 (GetScriptFather)
650 This function returns the identification number of the script
651 father.
652
653
654 (ReceivFromScript {int})
655 This function returns the message sent by the script numbered
656 int.
657
658
659 (RemainderOfDiv {int1 int2}): t
660 This function returns the remainder of the division (int1/int2).
661
662
663 (GetTime)
664 This function returns the time in seconds.
665
666
667 (GetPid)
668 This function returns the process id of the script.
669
670
671 (Gettext {str})
672 This function return the translation of str by using the locale
673 catalog(s) defined with UseGettext.
674
675
676 (SendMsgAndGet {comId} {cmd} bool)
677 Sends the command cmd with identifier comId to an external pro‐
678 gram ready to communicate with the script using a protocol spe‐
679 cific to FvwmScript. If bool is 0 FvwmScript does not wait for
680 an answer from the external program. In this case the returned
681 value is 1 if the message can be sent to the external program
682 and 0 if this is not the case. If bool is 1, then FvwmScript
683 waits for an answer from the external program and the return
684 value is this answer (a line of no more than 32000 characters).
685 If the communication fails, the returned value is 0. See the
686 section A COMMUNICATION PROTOCOL for a description of the commu‐
687 nication protocol used.
688
689
690 (Parse {str} int)
691 where str must be a string of the form:
692 X1S1X2S2X3S3...SnXn
693 where the Xn are numbers containing four decimal digits and
694 where Sn are strings of length exactly Xn. The returned value is
695 the string Sint. If int is out of range (e.g., >n) the returned
696 value is the empty string. If str is not of the specified form,
697 the return value is unpredictable (but empty in the average).
698 This function is useful to handle strings returned by the
699 SendMsgAndGet function.
700
701
702 (LastString)
703 This function returns the "current working string" for the Key
704 instruction and the SendString command (see the COMMANDS sec‐
705 tion). At startup this string is empty, but when a Key binding
706 is detected (respectively, a SendString command is received),
707 then this string is set to the string associated to the instruc‐
708 tion (respectively, to the command).
709
710
712 There are three kinds of conditional loops. The instruction "If-Then-
713 Else" has the following syntax:
714 If $ToDo=={Open xcalc} Then
715 Do {Exec xcalc &} # List of instructions
716 Else
717 Begin
718 Do {Exec killall xcalc &} # List of instructions
719 Do {Exec echo xcalc killed > /dev/console}
720 End
721 The second part "Else-Begin-End" is optional. If the loop contains only
722 one instruction, Begin and End can be omitted. The instruction "While-
723 Do" has the following syntax:
724 While $i<5 Do
725 Begin
726 Set $i=(Add i 1) # List of instructions
727 End
728 Two strings can be compared with "==" and two numbers can be compared
729 with "<", "<=", "==", ">=", ">". The loop "For-Do-Begin-End" has the
730 following syntax:
731 For $i=1 To 20 Do
732 Begin
733 Do {Exec xcalc &} # List of instructions
734 End
735
736
738 The following fvwm command may be executed at any time
739
740 SendToModule ScriptName SendString id sig str
741
742 it sends to any module with alias or name which matches ScriptName the
743 string
744
745 SendString id sig str
746
747 When an FvwmScript receives such a message it sends to the Widget id
748 the signal numbered sig and the string str can be obtained with the
749 LastString function. Let us give an example. Say that you have a
750 script MyScript with the widget:
751 Widget 50
752 Property
753 Type PushButton
754 Title {Quit}
755 ...
756 Main
757 Case message of
758
759 SingleClic:
760 Begin
761 Quit
762 End
763
764 1 :
765 Begin
766 Set $str = (LastString)
767 If $str == {Quit} Then
768 Quit
769 Else
770 ChangeTitle 33 $str
771 End
772
773 End
774 Then the command
775 SendToModule MyScript SendString 50 1 str
776 forces MyScript to exit if str is equal to "Quit" and if not it changes
777 the title of Widget 33 to str.
778
779
780 This command can be used to change the window title
781
782 SendToModule ScriptName ChangeWindowTitle newTitle [oldTitle]
783
784 it causes that any module with alias or name which matches ScriptName
785 changes its associated window title to newTitle. The optional argument
786 oldTitle makes sense when there are several instances of the same
787 script. It permits one to avoid changing the name of all these
788 instances by specifying the name of the window associated to the target
789 script (see the example below).
790
791 + I Module FvwmScript FvwmStorageSend "/dev/hda6"
792 + I Wait FvwmStorageSend
793 + I SendToModule FvwmStorageSend ChangeWindowTitle HDA6
794 + I Module FvwmScript FvwmStorageSend "/dev/hda1"
795 + I Wait FvwmStorageSend
796 + I SendToModule FvwmStorageSend ChangeWindowTitle HDA1 FvwmStorageSend
797
798 Without the FvwmStorageSend argument in the last case, the SendToModule
799 command would have changed to HDA1 the name of both instances of Fvwm‐
800 StorageSend.
801
802
803
805 You will find examples of scripts in the fvwm configuration directory.
806
807 FvwmScript-BellSetup, FvwmScript-KeyboardSetup, FvwmScript-PointerSetup
808 and FvwmScript-ScreenSetup are a set of scripts that modify X settings.
809 These scripts save preferences into a file named ~/.xinit-fvwmrc (If
810 you want to use another file name, give it as the first argument of the
811 script). If you want to load these preferences at every startup, you
812 have to include the line ".xinit-fvwmrc" in your .xinitrc (or .xses‐
813 sion) file before starting fvwm.
814
815 FvwmScript-BaseConfig modifies fvwm focus and paging mouse policy, win‐
816 dow placement, opacity and other features of the move and resize com‐
817 mands, snap attraction and shading animation. This script saves pref‐
818 erences into a file named .FvwmBaseConfig in the user's data directory
819 (i.e., $HOME/.fvwm or $FVWM_USERDIR if set). If you want to load these
820 preferences at every startup you must add the line "Read .FvwmBaseCon‐
821 fig" in your fvwm configuration file. If you want to use another file
822 name, give it as the first argument of the script. When you click on
823 Ok or Apply an fvwm function that you may define named BaseConfigOkFunc
824 or BaseConfigApplyFunc is called. This allows for reloading specific
825 application styles that the script has destroyed (e.g., AddToFunc
826 BaseConfigOkFunc I Read MyAppStyle).
827
828 FvwmScript-Buttons is a buttons panel which can replace FvwmButtons
829 (this script supports popup menus and requires xload, xclock, Fvwm‐
830 Pager, TkDesk). FvwmScript-Colorset allows you to edit your colorset.
831 FvwmScript-Date allows you to set date and time. FvwmScript-File‐
832 Browser is a file browser used by the other scripts. FvwmScript-Find
833 is an elementary front-end to find. FvwmScript-Quit allows one to quit
834 fvwm, restart fvwm or some other window manager, or shut down and
835 reboot the computer. FvwmScript-ScreenDump is a screen dumper. Fvwm‐
836 Script-WidgetDemo is a pure example script. See the next section for
837 FvwmScript-ComExample.
838
839
841 FvwmScript is a weak (but simple) programming language. If you need to
842 deal with a lot of data and/or you need to use complex algorithms you
843 should use an external program (in perl for example) and "send" the
844 desired information to your FvwmScript script. The first approach is to
845 use the GetOutput function. This is simple but you should rerun your
846 external program each time you need information from it (and this may
847 cause performances problems). The second approach is to use the
848 SendMsgAndGet function which extends FvwmScript by using any program‐
849 ming language which can deal with named pipes (fifos). We describe this
850 solution in this section. (A third approach is to use fvwm-themes-com
851 from the fvwm-themes package, but in fact the SendMsgAndGet method is
852 an implementation of fvwm-themes-com inside FvwmScript and this gives
853 better performance).
854
855 Basically, you start an "external" program (the program for short) from
856 your FvwmScript script (the script for short). This program runs in the
857 background and you use the SendMsgAndGet function in your script to ask
858 questions or to give instructions to the program. The program must
859 strictly respect a certain communication protocol. First of all there
860 is an identifier comId for the communication, it should contain the
861 process id of the script for a good implementation of the protocol (use
862 the GetPid function and pass the comId via an option to the program).
863 The protocol uses two fifos, in the fvwm user directory, named: .tmp-
864 com-in-comId and .tmp-com-out-comId. The program should create and
865 listen on the .tmp-com-in-comId fifo. Then, when FvwmScript executes a
866 function of the form:
867
868 Set $answer = (SendMsgAndGet {comId} {cmd} bool)
869
870 FvwmScript writes the cmd on this fifo. This way the program can read
871 the cmd and can execute the appropriate action (it should remove the in
872 fifo to support multi-communications). If bool is 0, FvwmScript does
873 not wait for an answer from the program and return 1 if the previous
874 actions succeed and 0 if they failed (then the program should "go back"
875 to the in fifo). If bool is 1, then FvwmScript waits (20 sec) for an
876 answer from the program and in turn returns the answer to the script
877 (note that bool is not passed to the program as it must know which com‐
878 mands need an answer). To answer, the program creates the .tmp-com-out-
879 comId fifo and writes the answer on it. The program should wait until
880 FvwmScript reads the answer and then it should remove the out fifo and
881 go back to the in fifo. The answer should consist of one line of no
882 more than 32000 characters (take a look at the Parse function to handle
883 multiple lines as one line).
884
885 A simple way to understand this protocol and to write scripts and pro‐
886 grams that use it is to take a look at the (not useful) example Fvwm‐
887 Script-ComExample and fvwm-script-ComExample.pl (that can found in the
888 fvwm data directory). Moreover, this implementation of the protocol
889 solves questions as: What to do if the script exits for a bad reason?
890 What to do if the program exits for a bad reason? ...etc.
891
892
894 FvwmScript crashes if widgets are accessed that have not been defined.
895
896
898 Frederic Cordier (cordie97@cui.unige.ch or f-cord96@univ-
899 lyon1.fr).
900
901
903 Eddy J. Gurney (eddy@gizmo.aa.ans.net).
904
905
906
9073rd Berkeley Distribution 06 November 2016 (2.6.7) FvwmScript(1)