#!/usr/sbin/install-menu
# Generates flwm menus for all registered applications.
compat="menu-1"

!include menu.h

compat="menu-2"

function mod($var,$com)=$var " \"" 
          title() ifnempty($hotkey,"&" toupper($hotkey)) 
          "\" exec " $com " &\n" 
	  ifelse(
	   $icon,
	   ifelsefile(
	    $icon, 
	    "MiniPixmap \"" $icon "\"\n",
	    "MiniPixmap \"mini-app.xpm\"\n"),
	   "MiniPixmap \"mini-app.xpm\"\n");


function restart($var,$com)=" " $var " \"" 
          title() ifnempty($hotkey,"&" toupper($hotkey)) 
          "\" " $com "\n";

function ex($com)=mod("Exec",$com);

# Make menus into directories and entries into files; deal with entries that
# contain slashes like "Communicator (static/461) Browser"
genmenu=parent($section) "/" replacewith($title, "/", "_") ifelse($command, "", "/");

rootprefix="/etc/X11/afterstep/hookdir";
userprefix=".afterstep";
treewalk=(M);
rootsection="/Debian";

#preoutput= "# This file was automatically generated (see /usr/doc/menu).\n# DO NOT EDIT!\n";
preoutput="";

# Clean-up files we may have generated in an earlier run first.
prerun="find " prefix() " -type f -exec grep -q '^Exec' {} \\; -exec rm {} \\; ; find " prefix() " -type d -print0 | xargs -0 rmdir --ignore-fail-on-non-empty";
#prerun="find " prefix() " -type f -exec grep -q 'DO NOT EDIT' {} \\; -exec rm {} \\; ; find " prefix() " -type d -print0 | xargs -0 rmdir --ignore-fail-on-non-empty";

# And make the generated scripts executable afterwards.
postrun="find " prefix() " -type f -print0 | xargs -0 chmod a+x";

supported;
  asmodule=   mod("Module", $command);
  fvwmmodule= mod("Exec",   $command);
  x11fvwm=    ex($command);
  wm=	restart("Restart",$command);
  x11=	ex($command);
  text=	ex(term());
endsupported;

mainmenutitle="";
submenutitle= "";

startmenu="";
endmenu="";
