#!/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($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,"stop") "\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"))
	ifelse($extra_opt, $extra_opt, ifnempty($kde_opt, $kde_opt)) "\n"
	"OnlyShowIn=KDE;\n";

#	"Exec=" $command "\n"

#outputencoding="UTF-8";

supported;
 kde = AppEntry("false");
# x11 = AppEntry("false");
# text = AppEntry("true");
endsupported;

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

treewalk = "M";

genmenu = ifnempty($command,tolower( "kde-" replacewith( ifelse($extra_filename, $extra_filename, $title) ,"/ ","_") ".desktop"));

rootsection = "";

prerun = "rm -rf " prefix() "/kde-*";

preoutput = "";

rootprefix = "/usr/share/applications-alt";

userprefix = ".local/share/applications-alt";
