Place of "Test" commands

Hi,

Does it really matter if I place “Test” command before or after “+ I” “*FvwmPager:…”?

For example what is better?

DestroyFunc enter_handler AddToFunc enter_handler Test (EnvMatch HOSTNAME cygwin) + I autohide Launcher 250 2500 S Test (EnvMatch HOSTNAME linux) + I autohide Launcher 250 500 S

or

[code]DestroyFunc enter_handler
AddToFunc enter_handler

  • I Test (EnvMatch HOSTNAME cygwin) autohide Launcher 250 2500 S
  • I Test (EnvMatch HOSTNAME linux) autohide Launcher 250 500 S[/code]

I’m trying to have one config file for cygwin and linux systems and I have many of such tests to make the “config” file easily portable.

Thanks.

This is bad because now you rely on the ordering of “AddToFunc” here being the last one before your Test conditions are run. This is very easily broken if you shift your config around. Also, note that without putting those Test lines in a function, you’re always going to evaluate them if your config is re-read by FVWM – which may well result in duplicte entries in “enter_handler” or some other function.

This one is better, because it always evaluates in the function context of “enter_handler”, without relying on the side-effects with your first example.

I am assuming that you’re setting HOSTNAME in FVWM’s environment as well then? SInce it’s not exported in the environment FVWM usually runs in.

– Thomas Adam

Thank you for quick answer.
Yeah, first I had a problem with debugging what is wrong under linux, since under cygwin $HOSTNAME env. var. is exported by default, then I realized that in linux I have to export it adding a line in .bashrc.

What about the following 2 pieces of code. Here imho I have no choice where to put ‘Test’ commands other than in the begineeng.

[code]DestroyMenu FvwmRootMenu
AddToMenu FvwmRootMenu “Root Menu [Alt-F5]” Title

  • “&Xterm%24x24/terminal.png%” FvwmXTerm
  • “&FireFox%24x24/firefox.png%” FvwmFireFox
  • “&Emacs%24x24/emacs.png%” FvwmEmacs
  • “&Gimp%24x24/gimp.png%” FvwmGimp
  • “&Inkscape%24x24/inkscape.png%” FvwmInkscape
  • “&mc%24x24/xterm.png%” Exec exec xterm -e mc
  • “” Nop
  • “&Programs%24x24/programs.png%” Popup FvwmProgramsMenu
    Test (EnvMatch HOSTNAME debian) + “&Debian programs%24x24/programs.png%” Popup DebianMenu
  • “” Nop
  • “&Restart FVWM [A-F1]%24x24/restart.png%” Restart
  • “E&dit fvwm config%24x24/edit_config.png%” FvwmEditConfig
  • “&Quit FVWM%24x24/quit4.png%” Quit
    Test (EnvMatch HOSTNAME debian) + “” Nop
    Test (EnvMatch HOSTNAME debian) + “Reboot%24x24/reboot3.png%” Exec exec sudo /sbin/reboot
    Test (EnvMatch HOSTNAME debian) + “Halt%24x24/shutdown.png%” Exec exec sudo /sbin/halt[/code]

DestroyModuleConfig Launcher: * Test (EnvMatch HOSTNAME cygwin) *Launcher: Geometry 1272x32-0-0 Test (EnvMatch HOSTNAME debian) *Launcher: Geometry 1680x32-0-0 Test (EnvMatch HOSTNAME cygwin) *Launcher: Columns 38 Test (EnvMatch HOSTNAME debian) *Launcher: Columns 48 *Launcher: Rows 2 *Launcher: Frame 0 *Launcher: Colorset 11 *Launcher: Padding 0 0 *Launcher: BoxSize fixed *Launcher: Font "xft:HandelGotD:size=9" *Launcher: (1x2, Colorset 10, Icon 32x32/programs.png, Action (Mouse 1) `Menu FvwmRootMenu`) *Launcher: (1x2, Colorset 10, Icon 32x32/xterm.png, Action (Mouse 1) FvwmXTerm) *Launcher: (1x2, Colorset 10, Icon 32x32/emacs.png, Action (Mouse 1) FvwmEmacs) *Launcher: (1x2, Colorset 10, Icon 32x32/iceweasel.png, Action (Mouse 1) FvwmFirefox) *Launcher: (1x2, Colorset 10, Icon 32x32/gimp.png, Action (Mouse 1) FvwmGimp) *Launcher: (1x2, Colorset 10, Icon 32x32/inkscape.png, Action (Mouse 1) FvwmInkscape) *Launcher: (1x2, Colorset 10, Icon 32x32/desktop128.png, Action (Mouse 1) Function ShowDesktop) *Launcher: (2x2, Colorset 10, Center, Frame 1, Swallow (NoClose, UseOld) FvwmPager 'Module FvwmPager *') Test (EnvMatch HOSTNAME cygwin) *Launcher: (25x2, Colorset 10, Center, Frame 1, Swallow (NoClose) "FvwmIconMan" 'Module FvwmIconMan') Test (EnvMatch HOSTNAME debian) *Launcher: (35x2, Colorset 10, Center, Frame 0, Swallow (Respawn, NoClose, UseOld) "FvwmIconMan" 'Module FvwmIconMan') *Launcher: (2x2, Colorset 11, Center, Frame 0, Swallow (NoClose, UseOld) "stalonetray" 'Exec exec stalonetray --no-shrink') *Launcher: (2x2, Colorset 11, Center, Frame 0, Swallow dclock 'FvwmScript dclock 10')

Or is it batter to have two Launchers (LauncherCyg and LauncherLinux) and have
adequate “Test” conditions in StartFunction?

[code]DestroyFunc StartFunction
AddToFunc StartFunction

  • I Test (Init) Test (EnvMatch HOSTNAME cygwin) Exec exec fvwm-root -r $[fvwm_wallpapers]/gentoo1272x969.png
  • I Test (Init) Test (EnvMatch HOSTNAME linux) Exec exec $[fvwm_root] gentoo.png
  • I Test (Init) Test (EnvMatch HOSTNAME linux) Exec exec gkrellm
  • I Test (Init) Exec xterm
  • I Test (EnvMatch HOSTNAME cygwin) Module FvwmButtons LauncherCyg
  • I Test (EnvMatch HOSTNAME linux) Module FvwmButtons LauncherLinux[/code]

That is fine, because when FVWM reads its config file, it does so on a single pass through, so the above will interpolate once, without relying on anything before it.

That’s a completely different question to your first one, above. But you do need this one anyway if you want to selectively load modules based on host in this way.

– Thomas Adam

Thanks again.
So in the case of adding items to a menu, should it also be fine like this?

[code]DestroyMenu FvwmRootMenu
AddToMenu FvwmRootMenu “root Menu [Alt-F5]” Title

  • “” Nop
  • “&Programs%24x24/programs.png%” Popup FvwmProgramsMenu
    Test (EnvMatch HOSTNAME debian) + “&Debian programs%24x24/programs.png%” Popup DebianMenu
  • “” Nop
  • “&Restart FVWM [A-F1]%24x24/restart.png%” Restart
  • “E&dit fvwm config%24x24/edit_config.png%” FvwmEditConfig
  • “&Quit FVWM%24x24/quit4.png%” Quit
    Test (EnvMatch HOSTNAME debian) + “” Nop
    Test (EnvMatch HOSTNAME debian) + “Reboot%24x24/reboot3.png%” Exec exec sudo /sbin/reboot
    Test (EnvMatch HOSTNAME debian) + “Halt%24x24/shutdown.png%” Exec exec sudo /sbin/halt[/code]

Yes, that’s fine.

– Thomas Adam