#!/usr/bin/install-menu
#I need menu-1.4!
# arch-tag: 73ccd6e4-fcf8-4b3f-8672-f61ae101cab5

compat="menu-1"

!include menu.h
!include lang.h

outputencoding="LOCALE"

# how to create menus
# So, if the title contains $[gt., 
#   we just print + title, or
# else
#    we escape all the double-quotes in the title,
#    and we replace the first ocurence of the hotkey with an &
# Finally, we print 
#    If there is an icon defined, print %icon file%, else leave it blank
#    First argument
#    command argument
function start($var,$com)=\
  "+ \"" ifelse(ifneq(replace(title(), "$[gt.", "#"), title(), "GETTEXT"), \
                  title(),                                                 \
                  escfirst(esc(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

# Usage:
#   Read /etc/X11/fvwm/menudefs.hook
#   Popup /Debian

# 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).  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.

# replace any spaces in the section with undescores,
# and put the title on top
startmenu=   "DestroyMenu \"" replacewith($section," ","_") "\"\n" \
             "AddToMenu   \"" replacewith($section," ","_") "\" \"" \
                 title() "\" Title Top\n"
endmenu=     "\n"

# This is how to define a menu entry that pops up another entry
# Whoof. Write + ", replace the first hotkey in the title with an &
# If there is an icon, add % icon-file %,  "
# add Popup , followed by the section replacing all spaces with underscores
submenutitle= "+ \"" escfirst(title(),$hotkey,"&") \
           cond_surr(icon(),"%","%") "\" Popup \"" \
           replacewith($section," ","_") "\"\n"

# The menu file to generate
genmenu=   "menudefs.hook"

# the prefix every $section variable gets. 
rootsection="/Debian"

# The prefix to use when running as root 
rootprefix="/etc/X11/fvwm/"

#Technical note: For historical reason, userprefix treat path starting
#with 2 / as absolute and with 0 or one / as relative to $HOME. This
#is why I added a / before the $
#userprefix="/.fvwm/"
userprefix=shell("echo -n /${FVWM_USERDIR-.fvwm}")

# c  : dump children of menu.
# m  : dump this menu's $submenutitles
# (  : dump $startmenu
# )  : dump $endmenu
# M  : dump all $submenutitles of this menu and this menu's children.
treewalk="c(m)"

mainmenutitle = "Debian Menu"
# printed to the beginning of each output file
preoutput="#!/bin/bash\n# This file is autogenerated by fvwm update-menus method\n# Do not edit - any changes to this file will be lost\n";
hotkeycase="insensitive"
