#!/usr/sbin/install-menu
#   -*- mode: shell-script; -*-

compat="menu-1"
!include menu.h

###compat="menu-2"

# removed ifnempty($hotkey,"&" toupper($hotkey))
#  can't figure out how to do hotkeys properly...
# added MiniPixmap display

function findicon($filename)= \
    ifeqelse($filename, "", $defaulticon, \
    ifelsefile($filename, $filename, \
    ifelsefile("/usr/share/icons/mini/" $filename, "/usr/share/icons/mini/" $filename, \
    ifelsefile("/usr/share/icons/" $filename, "/usr/share/icons/" $filename, \
    ifelsefile("/usr/share/icons/hicolor/16x16/apps/" $filename, "/usr/share/icons/hicolor/16x16/apps/" $filename, \
    ifelsefile("/usr/share/icons/locolor/16x16/apps/" $filename, "/usr/share/icons/locolor/16x16/apps/" $filename, \
	"/usr/X11R6/share/afterstep/desktop/icons/mini-app.xpm"))))))\

function SubmenuEntry()= \
	"name " translate(lang(),title()) "\n" \
	"minipixmap "  ifelse($icon,findicon($icon),"folder") "\n" \
	"keepname\n"

function mod($var,$com)=" " $var " \"" \
          translate(lang(),title()) \
          "\" exec " $com "\n" \
          ifnempty($icon," MiniPixmap \"" findicon($icon) "\"\n") \

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

# This function does not used for now
function mytranslate($sec)=forall(replacewith($sec,"/",":"), "name", translate(lang(),$name)"/")

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

# start- and endmenu entries not needed because afterstep
# menu is a directory. submenutitle also removed.
startmenu=""
endmenu=""

# Standard preoutput breaks menu entries, removed
preoutput=""

# Clean up directory before making menu
prerun="rm -rf " prefix()

postrun="echo \"minipixmap " findicon("altlinux.png") " \" >" prefix() "/ALT\\\ Linux/.include; \
		 ln -s /usr/X11R6/share/afterstep/start " prefix() "/MainMenu"

# AfterStep start menu: single files containing the menu entries
# I coudn't turn off generating files for the submenu titles,
# so i just call them "nop" and they get removed by postrun.
#genmenu=parent(replacewith(mytranslate($section)," ","\ ")) 

genmenu=parent($section"/") ifelse($command,"","/.include") 
submenutitle=SubmenuEntry()

rootsection="ALT Linux"
rootprefix="/usr/share/afterstep/start/"
userprefix=".afterstep/start"
mainmenutitle="ALT Linux Menu"
