#!/usr/bin/install-menu
#
# debian menu method for the fvwm-crystal desktop environment
# Author: Michael Stilkerich <ms@mike2k.de>
#
compat="menu-1"

!include menu.h

compat="menu-2"

outputencoding="ISO-8859-1";

supported;
  x11=  "exec " $command " $@"; 
  text= "exec FvwmCommand \'A " $command  " $@\'";
endsupported;

# strip arguments from the command
function CommandWOArgs()=shell("sh -r -c 'echo -n $0' "
                       replace(
                       "\""
                       esc(stripdir($command), "\\$`\"")
                       "\"", " ", "\" \""));

# generate a file name in the fvwm-crystal appdb format.
# do nothing for sections
genmenu=ifeqelse($needs, "", "",
                $basesection "/~"
                replace(CommandWOArgs(), "~", "")
                "~" replacewith(title(), " /", "__")
                shell("/usr/share/fvwm-crystal/debian/createicon.sh \""
                  CommandWOArgs() "\" \"" icon() "\"")
                );
startmenu="";
endmenu="";

# the root of the menu is debian
rootsection="/debian";
rootprefix="/var/lib/fvwm-crystal/Applications";

# runnable as user, but will exit with error if debian Application subdir not
# writeable (masked out by user)
userprefix=".fvwm/Applications");

treewalk="M";

# remove the whole Debian menu and rebuild from scratch
prerun="rm -rf " prefix() rootsection();

# all menu files must be executable to show up in the menu
postrun="chmod -R +x " prefix() rootsection();
# fvwm2 somehow doesn't seem to like this more than once so
# we leave him alone
#postrun="chmod -R +x " prefix() rootsection() " && killall -USR1 fvwm2";

# executed upon update-menus --remove
removemenu="rm -rf " prefix() rootsection() " && sh /usr/share/fvwm-crystal/debian/createicon.sh --remove";

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