# generate_menu for Fluxbox
# Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org)
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

#!/bin/sh

FILENAME=menu.in

find_it() {
	if [ ! -z "$(which $1 2>/dev/null | grep "^/.*$1")" ]; then
		if [ -x "$(which $1)" ]; then
			shift
			$*
		else
			echo "$1 exists but it is not executable!  Check permissions."
		fi
	fi
}

append() {
	echo "	$*" >> $FILENAME
}

append_menu() {
	echo "$*" >> $FILENAME
}

# Start of menu

echo "[begin] (Fluxbox @VERSION@)" > $FILENAME

find_it xterm           append "[exec]   (xterm) {xterm -fg white -bg black
}"
find_it nedit           append "[exec]   (nedit) {nedit}"


append_menu "[submenu] (Browsers)"
	find_it netscape    append "[exec]   (netscape) {netscape}"
	find_it opera       append "[exec]   (opera) {opera}"
	find_it galeon      append "[exec]   (galeon) {galeon}"
	find_it mozilla     append "[exec]   (mozilla) {mozilla}"
	find_it konqueror   append "[exec]   (konqueror) {konqueror}"
append_menu "[end]"


append_menu "[submenu] (Editors)"
	find_it nedit       append "[exec]   (nedit) {nedit}"
	find_it vim         append "[exec]   (vim) {vim -g}"
	find_it xemacs      append "[exec]   (xemacs) {xemacs}"
	find_it gedit       append "[exec]   (gedit) {gedit}"
	find_it xedit       append "[exec]   (xedit) {xedit}"
	find_it kword       append "[exec]   (kword) {kword}"
	find_it kwrite      append "[exec]   (kword) {kwrite}"	
append_menu "[end]"


append_menu "[submenu] (Net)"
	find_it realplay    append "[exec]   (realplay) {realplay}"
	find_it licq        append "[exec]   (licq) {licq}"	
	find_it sylpheed    append "[exec]   (sylpheed) {sylpheed}"
	
	find_it gftp        append "[exec]   (gftp) {gftp}"
	find_it xchat       append "[exec]   (xchat) {xchat}"
	find_it irssi       append "[exec]   (irssi) {xterm -title irssi -e irssi}"
	find_it BitchX      append "[exec]   (BitchX) {xterm -title BitchX -fg white -bg black -e BitchX -N}"
	find_it bitchx      append "[exec]   (BitchX) {xterm -title BitchX -fg white -bg black -e bitchx -N}"
	find_it ircii       append "[exec]   (ircii) {xterm -title ircii -fg white -bg black -e ircii -s}"
append_menu "[end]"


append_menu "[submenu] (Graphics)"
	find_it gimp        append "[exec]   (gimp) {gimp}"
	find_it xv          append "[exec]   (xv) {xv}"
	find_it gqview      append "[exec]   (gqview) {gqview}"
	find_it xpaint      append "[exec]   (xpaint) {xpaint}"
	find_it kpaint      append "[exec]   (kpaint) {kpaint}"
	find_it kiconedit   append "[exec]   (kiconedit) {kiconedit}"
append_menu "[end]"


append_menu "[submenu] (Music)"
	find_it xmms        append "[exec]   (xmms) {xmms}"
	find_it gqmpeg      append "[exec]   (gqmpeg) {gqmpeg}"
	find_it xmixer      append "[exec]   (xmixer) {xmixer}"
	find_it gmix        append "[exec]   (gmix) {gmix}"
	find_it kmix        append "[exec]   (kmix) {kmix}"
	find_it grecord     append "[exec]   (grecord) {grecord}"
	find_it kmidi       append "[exec]   (kmidi) {kmidi}"
	find_it xplaycd     append "[exec]   (xplaycd) {xplaycd}"
	find_it soundtracker append "[exec]   (soundtracker) {soundtracker}"
append_menu "[end]"


append_menu "[submenu] (Terminals)"
	append "[exec]�(xterm) {xterm -fg white -bg black}"
	find_it gnome-terminal append "[exec] (gnome-terminal) {gnome-terminal}"
	find_it Eterm       append "[exec] (Eterm) {Eterm}"
	find_it konsole     append "[exec] (konsole) {konsole}"
	find_it aterm       append "[exec] (aterm) {aterm}"
	find_it rxvt        append "[exec] (rxvt) {rxvt}"
append_menu "[end]"


append_menu "[submenu] (Misc)"
	find_it acroread    append "[exec] (acroread) {acroread}"
	find_it gcalc       append "[exec] (gcalc) {gcalc}"
	find_it kcalc       append "[exec] (kcalc) {kcalc}"
	find_it kpackage    append "[exec] (kpackage) {kpackage}"
	find_it xgdb        append "[exec] (xgdb) {xgdb}"
	find_it ddd         append "[exec] (ddd) {ddd}"
	find_it xterm       append "[exec]   (tail access_log) {xterm -fg white -bg black -title access_log -e tail -f /var/log/access_log}"
append_menu "[end]"

append_menu "[submenu] (X utils)"
	find_it xpenguins   append "[exec] (xpenguins) {xpenguins}"
	find_it xcalc       append "[exec] (xcalc) {xcalc}"
	find_it xfontsel    append "[exec] (xfontsel) {xfontsel}"
	find_it xman        append "[exec] (xman) {xman}"
	find_it xload       append "[exec] (xload) {xload}"
	find_it xfig        append "[exec] (xfig) {xfig}"
	find_it xbiff       append "[exec] (xbiff) {xbiff}"
	find_it editres     append "[exec] (editres) {editres}"
	find_it viewres     append "[exec] (viewres) {viewres}"
	find_it xsnow       append "[exec] (xsnow) {xsnow}"
	find_it xclock      append "[exec] (xclock) {xclock}"
append_menu "[end]"

append_menu "[workspaces]   (Workspace List)"
append_menu "[submenu] (Styles) {Choose a style...}"
append_menu "[stylesdir] (@pkgdatadir@/styles)"
append_menu "[end]"
append_menu "[config] (Configuration)"
append_menu "[reconfig] (Reconfigure)"
append_menu "[restart] (Restart)"
append_menu "[exit] (Exit)"

append_menu "[end]"