#!/usr/sbin/install-menu
#I need menu-1.4!
#
#NOTE: the first line of this script _must_ be
# equal to "#!/usr/sbin/install-menu", otherwise update-menus
# will feed this script old-compat-mode data.
#
#More info: /usr/doc/menu/html.
#
# This version of the fvwm menu method is based on
# /usr/doc/menu/examples/fvwm2, and has been modified for the new fvwm
# package (containing FVWM 2.2) by Julian Gilbey <jdg@debian.org>,
# partially based on Austin Donnelly's version.

compat="menu-1"

!include menu.h

function start($var,$com)=\
            "+ \"" escfirst(title(),$hotkey,"&") \
            cond_surr(icon(),"%","%") "\" " $var " " $com "\n"
supported 
  fvwmmodule=  start("Module", $command)
  fvwmother=   start("",       $command)
  wm=          start("Restart",$command)
  x11fvwm2=    start("Exec exec",   $command)
  x11fvwm=     start("Exec exec",   $command)
  x11=         start("Exec exec",   $command)
  text=        start("Exec exec",   term())
endsupported

# Ok, "startmenu" is a little wacky, and comes in 4 parts:
# 1. If this is running for a user, then we do a DestroyMenu to
#    clear out the system one. Furthermore, if we're dealing with the
#    top-level /Debian menu, then add a title for it (normally done in
#    system.fvwm2rc), and re-read the main-menu-pre.hooks whose results
#    we merrily blew away earlier.  This is so that the
#    main-menu-pre.hooks work for users as well as system-wide.  Of
#    course, none of this happens if we're running as root to produce the
#    system-wide menudef.hook file.
# 2. We spit out an "AddToMenu /Foo/Bar/Baz" to start this menu.
# 3. We add a trailing newline to the lot.

startmenu=   "DestroyMenu \"" $section "\"\n" \
               ifeq($section, "/Debian", \
                 "AddToMenu \"/Debian\"\n" \
                 "Read /etc/X11/fvwm/main-menu-pre.hook Quiet\n" \
                 "Read .fvwm/main-menu-pre.hook Quiet\n") \
             "AddToMenu \"" $section "\" \"" title() "\" Title Top\n"
endmenu=     "\n"

submenutitle= "+ \"" escfirst(title(),$hotkey,"&") \
           cond_surr(icon(),"%","%") "\" Popup " $section "\n"
genmenu=   "menudefs.hook"
rootprefix="/etc/X11/fvwm/"
userprefix="/.fvwm/"
treewalk="c(m)"
mainmenutitle="Main Menu"
