#!/usr/sbin/install-menu
# freedesktop desktop entry spec - applications generation
# http://www.freedesktop.org/Standards/desktop-entry-spec
# Copyright 2004 - Chris Cheney
# Licensed under the GNU General Public License, version 2.

compat="menu-1"

!include menu.h

compat="menu-2"

function AppEntry($wm, $terminal) =
	"[Desktop Entry]\n"
	"Encoding=UTF-8\n"
	"Type=Application\n"
	"Name=" title() "\n"
	"GenericName=" ifnempty($genericname,$genericname) "\n"
	"Comment=" ifnempty($longtitle,$longtitle) "\n"
	"Icon=" ifelse($icon,$icon,"altlinux") "\n"
	"Exec=" ifelse($extra_command, $extra_command, $command ifnempty($accept_url,ifeqelse(tolower($accept_url),"true",ifnempty($multiple_files,ifeqelse(tolower($multiple_files),"true"," %U", " %u")),ifnempty($multiple_files,ifeq(tolower($multiple_files),"true"," %F")))))"\n"
	"Terminal=" $terminal "\n"
	"Categories=" "X-ALT" replacewith($basesection,"/ .","---") ";\n"
	ifnempty($mimetypes, "MimeType=" replacewith($mimetypes,",",";") "\n" )
	forall(languages(), "lang", "Name[" substr($lang, "0", "2") "]= " encode_translate($lang,title(), "utf8") "\n")
	ifnempty($longtitle, forall(languages(), "lang", "Comment[" substr($lang, "0", "2") "]=" encode_translate($lang,$longtitle, "utf8") "\n"))
	ifnempty($genericname,forall(languages(), "lang", "GenericName[" substr($lang, "0", "2") "]=" encode_translate($lang,$genericname,"utf8") "\n"))
	ifnempty($wm, "OnlyShowIn=" $wm ";\n")
	ifnempty($extra_opt, $extra_opt) "\n";

#outputencoding="UTF-8";

supported;
 gnome = AppEntry("GNOME", "false");
 kde = AppEntry("KDE", "false");
 x11 = AppEntry("", "false");
 text = AppEntry("", "true");
endsupported;

startmenu = "";
endmenu = "";
submenutitle = "";

treewalk = "M";

genmenu = ifnempty($command,tolower(ifeqelse($needs,"gnome", "gnome", ifeqelse($needs,"kde", "kde", "alt")) "-" replacewith( ifelse($extra_filename, $extra_filename, $title) ,"/ ","__") ".desktop"));

rootsection = "";

prerun = "mkdir -p "prefix()"; rm -rf "prefix()"/*";
postrun = "xdg-desktop-entry-spec-apps-postrun";

preoutput = "";

rootprefix = "/var/lib/menu/tmp_xdg_menu";

userprefix = ".local/share/tmp_xdg_menu";
