#!/usr/bin/install-menu
# xdg menu spec - menu generation
# http://www.freedesktop.org/Standards/menu-spec
# Also used as /etc/menu-methods/menu-xdg
# Copyright 2004 - Chris Cheney <ccheney@debian.org>
# Licensed under the GNU General Public License, version 2.

!include menu.h

compat="menu-2"
outputencoding="UTF-8";
outputlanguage="C";

function Dirs() =
	ifempty($section,ifroot(
	"<AppDir>/var/lib/menu-xdg/applications</AppDir>\n"
	"<DirectoryDir>/var/lib/menu-xdg/desktop-directories/menu-xdg</DirectoryDir>\n",
	"<DirectoryDir>"
	parent(parent(prefix()))
	"/.local/share/desktop-directories/menu-xdg</DirectoryDir>\n"));

function DirEntry() =
	Dirs()
	"<Name>" title() "</Name>\n"
	"<Directory>" "debian" replacewith(tolower($section),"/ ","--") ".directory" "</Directory>\n"
	"<Include>\n"
	"<Category>" "X-Debian" replacewith($section,"/ ","--") "</Category>\n"
	"</Include>\n";


supported;
 x11 = ;
 text = ;
endsupported;

startmenu = "<Menu>\n" DirEntry();
endmenu = "</Menu>\n";
submenutitle = "";

treewalk = "(M)";

genmenu = "debian-menu.menu";

prerun = "rm -rf " prefix() "/debian-menu.menu";

rootsection = "";

preoutput = "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 0.8//EN\"\n \"http://www.freedesktop.org/standards/menu-spec/menu-0.8.dtd\">\n<!-- Automatically generated do not edit -->\n";

rootprefix = "/var/lib/menu-xdg/menus";

userprefix = ".config/menus";
