~sourcemage/enthrall

2cba72f5287c730af0edf8418c4160c8684c88bd — root 13 years ago master
initial import
A  => COPYING +340 -0
@@ 1,340 @@
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

A  => ChangeLog +66 -0
@@ 1,66 @@
2009-08-14 Arjan Bouter <abouter@sourcemage.org>
	* version 0.8
	* added lxde and dmenu, fixed deskmenu system
	  menu location, removed netconf menuentry

2008-02-28 Arjan Bouter <abouter@sourcemage.org>
	* version 0.7
	* added several windowmanagers
	* fixed xfce
	* added a manpage

2007-08-25 Arjan Bouter <abouter@sourcemage.org>
	* added a jwm backend
	* version 0.6

2007-06-24 Arjan Bouter <abouter@sourcemage.org>
	* fixed removing of backup menu directories
	* version 0.5

2007-05-15 Arjan Bouter <abouter@sourcemage.org>
	* renamed ion -> ion3
	* added a dir for desktop files
	* fixed waimea backend
	* version 0.4

2007-01-01 Arjan Bouter <abouter@sourcemage.org>
	* added fvwm and fvwm-crystal backends
	* fixed openbox user menu

2005-04-10 Arjan Bouter <abouter@sourcemage.org>
	* Fixed ion's backend
	* version increased to 0.3.1

2005-04-01 Arjan Bouter <abouter@sourcemage.org>
	* Fixed xfce4-session's 'quit' menu entry
	* added afterstep backend
	* moved enthrall.conf from /etc/sorcery to /etc
	  to keep out of sorcery's way

2005-03-30 Arjan Bouter <abouter@sourcemage.org>
	* added xfce4-session backend
	* added all available backends to the
          output of --help
	* version updated to 0.2

2005-03-19 Arjan Bouter <abouter@sourcemage.org>
	* small fix in icewm's backend

2005-03-18 Arjan Bouter <abouter@sourcemage.org>
	* added --remove to enthrall

2005-03-18 Arjan Bouter <abouter@sourcemage.org>
	* added icewm backend
	* added version number and --version option

2005-03-03 Arjan Bouter <abouter@sourcemage.org>
	* fixed typos in --help

2005-02-13 Arjan Bouter <abouter@sourcemage.org>
	* fixed ion's backend

2005-02-12 Arjan Bouter <abouter@sourcemage.org>
	* enthrall.conf: fixed location of the backends

2005-02-11 Arjan Bouter <abouter@sourcemage.org>
	* moved Enthrall into this p4 section

A  => etc/enthrall.conf +86 -0
@@ 1,86 @@
## Enthrall -  global configuration
##
## These settings are defaults only, and will be overwritten on
## each update of Sourcemage. You can place you're own options in
## /etc/enthrall.local.conf
## Everything there will override these defaults
##

# This option sets the location where the main enthrall will store a temporary file
# which the backends can use.
SORTED_INVENTORY=/tmp/enthrall.sorted

# This option sets the directories in which invoke will scan for *.desktop files
# which contain menu info for installed applications.
# Please do me a favour and remove KDE related directories before you submit a bug.
# KDE uses non-standard .desktop files and WILL break enthrall.
DT_DIRS="$HOME/.apps /usr/share/applications /usr/share/applnk /usr/share/gnome/apps /opt/openoffice/share/kde/net /usr/lib/OpenOffice.org1.1.3/share/kde/net /usr/share/games/gnome/apps/Games/"

# Setting the enthrall backend directory
# Don't change unless you know what you are doing...
LIBENTHRALL="/var/lib/enthrall"

# The locations where enthrall will place the generated menus
# Modify this to the location relative to the "MENULOCATION"
BLACKBOX_MENU="/usr/share/blackbox/menu"
BLACKBOX_USER_MENU="$HOME/.blackbox/menu"
ENLIGHTENMENT_MENU="/tmp/enthrall-e16/sysmenu/enlightenment.menu"
ENLIGHTENMENT_USER_MENU="$HOME/enthrall-e16/enlightenment.menu"
FLUXBOX_MENU="/usr/share/fluxbox/menu"
FLUXBOX_USER_MENU="$HOME/.fluxbox/menu"
PEKWM_MENU="/etc/pekwm/menu"
PEKWM_USER_MENU="$HOME/.pekwm/menu"
GOLEM_MENU="/usr/share/golem/plugins/enthrall_menus/rc"
GOLEM_USER_MENU="$HOME/.golem/golem.menu"
ION_MENU="/etc/ion3/cfg_menus.lua"
ION_USER_MENU="$HOME/.ion3/cfg_menus.lua"
IDESK_MENU="/usr/share/idesk/default.lnk"
IDESK_USER_MENU="$HOME/.idesktop"
JWM_MENU="/etc/jwmrc-menu"
JWM_USER_MENU="$HOME/.jwm/jwmrc-menu"
AEWM_MENU="/etc/X11/aewm/clientsrc"
AEWM_USER_MENU="$HOME/.aewm/clientsrc"
PWM_MENU="/etc/pwm/menus-default.conf"
PWM_USER_MENU="$HOME/.pwm/pwm.menu"
QVWM_MENU="/usr/share/qvwm/qvwm.menu"
QVWM_USER_MENU="$HOME/.qvwm/qvwm.menu"
OPENBOX_MENU="/etc/xdg/openbox/menu.xml"
OPENBOX_USER_MENU="$HOME/.config/openbox/menu.xml"
WAIMEA_MENU="/usr/share/waimea/menu"
WAIMEA_USER_MENU="$HOME/.waimea/menu"
KAHAKAI_MENU="/usr/share/kahakai/menu"
KAHAKAI_USER_MENU="$HOME/.kahakai/menu"
DESKMENU_MENU="/etc/deskmenurc"
DESKMENU_USER_MENU="$HOME/.deskmenurc"
DMENU_MENU="/etc/dmenu"
DMENU_USER_MENU="$HOME/.dmenu"
### Ok, Windowmaker is a nightmare, one of the following menu formats.
### remember to swap enthrall.windowmaker with the corresponding wmaker.* 
### in /var/lib/enthrall/
## wmaker menu, old style menus
#WINDOWMAKER_MENU="/usr/share/WindowMaker/menu"
#WINDOWMAKER_USER_MENU="$HOME/GNUstep/Library/WindowMaker/menu"
## wmaker plmenu, new style menus
WINDOWMAKER_MENU="/etc/WindowMaker/WMRootMenu"
WINDOWMAKER_USER_MENU="$HOME/GNUstep/Defaults/WMRootMenu"
ICEWM_MENU="/usr/share/icewm/menu"
ICEWM_USER_MENU="$HOME/.icewm/menu"
LXP_MENU="/usr/share/lxp-icewm/menu"
LXP_USER_MENU="$HOME/.lxp-icewm/menu"
XFCE_MENU="/etc/xdg/xfce4/desktop/menu.xml"
XFCE_USER_MENU="$HOME/.config/xfce4/desktop/menu.xml"
AFTERSTEP_MENU="/usr/share/afterstep/start"
AFTERSTEP_USER_MENU="$HOME/.afterstep/start"
FVWM_MENU="/usr/share/fvwm/SourceMage_menu"
FVWM_USER_MENU="$HOME/.fvwm/SourceMage_menu"
FVWM_CRYSTAL_MENU="/usr/share/fvwm-crystal/fvwm/Applications/SourceMage"
FVWM_CRYSTAL_USER_MENU="$HOME/.fvwm-crystal/Applications/SourceMage"
FBPANEL_MENU="/usr/share/fbpanel/menu"
FBPANEL_USER_MENU="$HOME/.fbpanel/menu"

# Tell enthrall which submenus you want in your menu.
# This is a space separated list of submenus which will be in your menus.
# Keep in mind that all available .desktop files will be scanned for these submenus.
# And the entries go into the 1st menu which "fits".
# So it is likely that the "My-AllTime-Favourites" menu will be empty ;)
SUBMENUS="User XTerminals Audio BBtools Development Editor File Game Graphic Network Office Security System Video WMTools"

A  => install +62 -0
@@ 1,62 @@
#!/bin/bash

#
# For unknown reasons `$filter=...; find . $filter` doesn't work, so this function
# encapsulates the filters necessary to strip CVS files and EMACS temporary files
function install__find_non_volatile() {
  find "$@" -not -type d -and -not -path '*CVS*' -and -not -name '.#*' -and -not -name '*~' -and -not -path '*.svn*' -and -not -path '*.arch-id*'
}

if [[ $1 ]] ; then
  INSTALL_ROOT=$1
else
  INSTALL_ROOT=""
fi
# First clean out all libraries.
echo "Cleaning out all old enthrall libraries..."
ENTHRALL_LIBS=${INSTALL_ROOT}/var/lib/enthrall
rm -rf $ENTHRALL_LIBS

echo "Installing scripts and libraries"
# Install the executables
install__find_non_volatile etc usr/bin var/lib | (
  while read SCRIPT; do
    /usr/bin/install --owner=root --group=root --mode=755 -pD "${SCRIPT}" "${INSTALL_ROOT}/${SCRIPT}"
  done
)

# Install the man pages
echo "Installing man pages"
install__find_non_volatile usr/share/man | (
  while read DOC; do
    /usr/bin/install --owner=root --group=root --mode=644 -pD "${DOC}"    "${INSTALL_ROOT}/${DOC}"
    gzip  --best  -f "${INSTALL_ROOT}/${DOC}"
  done
)

# Install the GNU General Public License
  /usr/bin/install --owner=root --group=root --mode=644 -pD "COPYING"   "${INSTALL_ROOT}/usr/share/doc/enthrall/COPYING"

# Install the ChangeLog
  /usr/bin/install --owner=root --group=root --mode=644 -pD "ChangeLog"   "${INSTALL_ROOT}/usr/share/doc/enthrall/ChangeLog"

#---------------------------------------------------------------------
##=back
##
##=head1 LICENSE
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
#---------------------------------------------------------------------

A  => usr/bin/enthrall +409 -0
@@ 1,409 @@
#!/bin/bash
#---------------------------------------------------------------------
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
## @Copyright Copyright 2004 by Arjan Bouter for Source Mage GNU/Linux
## @Licence Relased under the GNU GPL version 2
#---------------------------------------------------------------------


function help_me {
  cat << EOF

Enthrall is a script that will generate menus for various windowmanagers.
By default it will generate menus for all windowmanagers wich have
a backend written for them. You can optionally give a few windowmanagers
as options to enthrall and it will only build their respective menu.

The default location to place the generated menus is in the location
where the windowmanagers expect them. You can either change the location
in /etc/enthrall.conf or move/link the menus to their place
in your homedir.

If your favorite windowmanager is not supported,
please write the backend for it yourself. It really isn't hard.
You can try asking REALLY nice in #sourcemage on irc.freenode.net
and we might want to help you out...

Usage:
enthrall [options]

Options available:
    version   : Displays version number and exits
    help      : Displays this text.
    inventory : only generates menu index and does not generate any menu.
                his might then be used in your own, far more advanced,
		menu generating script.  ;)
    remove    : removes the backups of all menus
    <windowmanager name>  : generates only the menu for <windowmanager name>

The windowmanagers supported:
aewm, afterstep, blackbox, deskmenu, fluxbox, fvwm, fvwm-crystal, golem, icewm, ion3, kahakai, openbox, pekwm, pwm, qvwm, waimea, windowmaker (both menu formats) and xfce-session.

EOF
  exit 0
}

function check_own_menu {
# check if root is running enthrall
# if so, do we make root's menu or local menus
 OWN_MENU=true
 if [ "$UID" == "0" ]; then
   echo "I noticed you ran me as root. Well master, do you want to work"
   echo "on your own menus or those for everyone?"
   while :; do
     echo -n "please answer y for your own menus or n for everyone:    "
     read answer
     case "$answer" in
       Y|y) OWN_MENU=true
            export OWN_MENU
            break ;;
       N|n) OWN_MENU=false
            export OWN_MENU
            break ;;
     esac
   done
 fi
 echo ""
}

function get_dt_dirs {
# gets the list of available locations for .desktop files
  local dt_location=""
  for dt_location in $DT_DIRS ; do
    [ -d $dt_location ] && DT_LOCATIONS="$DT_LOCATIONS $dt_location"
  done
  # return 0, just in case the last dir in DT_DIRS doesn't exist
  return 0
}


function get_dt_files {
# gets the list of available .desktop files

 DT_FILE_LIST=$(find $DT_LOCATIONS -name '*.desktop')

}


function read_dt_files {
# reads the list of .desktop files and drops the summary in an inventory
# some wm's, like qvwm need the full path to icons
# that is a task for the backend, NOT enthrall...

local dt_file=""
  not_in_menu="true"
  for dt_file in $DT_FILE_LIST ; do
    echo -n "."
    PARSED="$( awk -F= '
      $1=="Name" {
                  gsub("^\"", "", $2);
                  gsub("\"$", "", $2);
		  APP=$2;
                 }
      $1=="Comment" {
                  gsub(":", "-", $2);
		  DESC=$2;
                 }
      $1=="Categories" {
                  gsub(";$", "", $2);
                  LOC=$2;
                 }
      $1=="Icon" {
                  ICON=$2;
                 }
      $1=="TryExec" {
         if($2~/^\"(.*)\"$/) {
                  gsub("^\"", "", $2);
		  gsub("\"$", "", $2); }
                  TryExec=$2;
                 } 
      $1=="Exec" {
         if($2~/^\"(.*)\"$/) {
                  gsub("^\"", "", $2);
                  gsub("\"$", "", $2); }
                  Exec=$2;
                 } 
      $1=="Terminal" {
                  TERM=$2;
                 }
      $1=="OnlyShowIn" {
                  OnlyShowIn=$2;
                 }
      $1=="NoDisplay" {
                  NoDisplay=$2;
                 }

      END {
           if(TryExec!="") EXEC=TryExec; else EXEC=Exec;
           if(DESC=="") DESC=APP;
           if(LOC=="") LOC="Application;Unspecified";
           if(LOC=="Application") LOC="Application;Unspecified";
           if(TryExec!="") EXEC=TryExec; else EXEC=Exec;
	   printf("%s:%s:%s:%s:%s:%s:%s:%s",APP,DESC,LOC,ICON,EXEC,TERM,OnlyShowIn,NoDisplay);
          } ' $dt_file
      )"

    APP="$(echo $PARSED|awk -F: '{print $1}')"
    DESC="$(echo $PARSED|awk -F: '{print $2}')"
    LOC="$(echo $PARSED|awk -F: '{print $3}')"
    ICON="$(echo $PARSED|awk -F: '{print $4}')"
    EXEC="$(echo $PARSED|awk -F: '{print $5}')"
    TERM="$(echo $PARSED|awk -F: '{print $6}')"
    OnlyShowIn="$(echo $PARSED|awk -F: '{print $7}')"
    NoDisplay="$(echo $PARSED|awk -F: '{print $8}')"

    [ "$TERM" == "1" ] && TERM="true"
    [ "$TERM" == "True" ] && TERM="true"

    [ "$NoDisplay" == "1" ] && NoDisplay="true"
    [ "$NoDisplay" == "True" ] && NoDisplay="true"

# variables are now filled with values, but we only want menu entries if the
# executable really exists

    local test_exec="$( echo "$EXEC" |cut -f1 -d" " )"
    local path_env="$( echo $PATH | sed "s/:/ /g" )"

    [ -x "$test_exec" ] && not_in_menu=""

    [ -z "$not_in_menu" ] || for path_dir in $path_env; do
        [ -x "$path_dir/$test_exec" ] && not_in_menu=""
      done
    ! [ -z "$APP" ] && [ "$NoDisplay" != "true" ] && [ -z "$not_in_menu" ] && [ -z "$OnlyShowIn" ] && INVENTORY="$(echo "$INVENTORY" ; echo "$APP:$DESC:$LOC:$EXEC:$TERM:$ICON")"

  not_in_menu="true"

  done
  echo ""
   INVENTORY="$(echo "$INVENTORY"|sort -u)"
}


function gen_inventory {
# generates inventory of installed spells which have menu entries
  echo "Generating inventory, please be patient."
  get_dt_dirs || echo "Oops, couldn't find any directory with *.desktop files"
  get_dt_files || echo "Oops, couldn't find any *.desktop file in specified directories"
  read_dt_files || echo "Oops, couldn't read the found *.desktop files"
}


function scan_backends {
# scans for available enthrall backends
# and checks if the windowmanager in question is installed
  local backend_found=""
  local check_wm=""
  echo "Checking installed windowmanagers"
  [ -z "$ARGS" ] && for backend_found in $LIBENTHRALL/* ; do
       check_wm="$(echo $backend_found|grep "enthrall\."|cut -f2 -d. )"
       [ "$(gaze installed $check_wm | tail -n1)" != "not installed" ] &&
       echo -n "." &&
       BACKENDS_AVAILABLE="$BACKENDS_AVAILABLE $check_wm"
     done
  ! [ -z "$ARGS" ] && for check_wm in $ARGS ; do
       [ "$(gaze installed $check_wm | tail -n1)" != "not installed" ] &&
       echo -n "." &&
       BACKENDS_AVAILABLE="$BACKENDS_AVAILABLE $check_wm"
     done
  [ -z "$BACKENDS_AVAILABLE" ] && {
    echo "None of the selected windowmanagers are installed, going any further would be useless."
    return 1
    }
  echo
  echo "Going to build a menu for: $BACKENDS_AVAILABLE"
  return 0
}

function scan_for_submenus {
# scans the inventory for submenus
# returns a list of submenus
  echo "$INVENTORY"|cut -f3 -d: |while read item ; do
    if ! [ -z "$item" ] ; then
      echo $item | sed "s/\;$//g"
    fi
  done
}


function filter_nonsense {
# filters out stupid menu categories
# no harm in filtering, even gnome and enlightenment do it
local sublist=$(scan_for_submenus \
  |sed -e "s/GNOME\;//g" -e "s/\;X-Ximian-Main//g" \
       -e "s/X-Ximian-Main\;//g" -e "s/\;X-Red-Hat-Base//g" )

  echo "$sublist"|sort -r -u
}

function clean_semicolon() {
# cleans out the semicolons from the input, one line at the time
  rawline="$*"
  cleanline=${rawline/\;/\\}
}


function order_inventory {
# Voodoo time, this takes the inventory and
# produces a sorted inventory, ready for the backends.
#
# Note:	replace "filter_nonsense" by "scan_for_submenus" to keep 
#       the submenus in the list exactly as specified in the 
#       .desktop files (including GNOME and RED-HAT-BASE submenus).
#

# Remember, the "Other" can not be in the list. it is filled with
# entries which do not fit in other lists.
  if [ -z "$SUBMENUS" ] ; then
    SUBMENUS="Audio Editor File Game Graphic Network Office Video"
  fi

  DONE=""

  echo "Sorting inventory, this can take a while"

  for submenu in $SUBMENUS ; do
    items="$(echo "$INVENTORY"|grep -i $submenu)"
    if ! [ -z "$items" ]; then
      echo "START_SUB $submenu" >> $SORTED_INVENTORY
      echo "$items" | while read menu_item; do
      isdone="$(echo "$DONE"|grep -x "$menu_item")"
        if ! [ "$isdone" ]; then
          echo "$menu_item" >> $SORTED_INVENTORY
        fi
      done
      echo "END_SUB" >> $SORTED_INVENTORY
    fi
    DONE="$(echo "$DONE" ; echo "$items")"
  done

# We need to add the sourcemage tools to the menu as they also don't provide
# their own .desktop files. Hmm, should I file a bug for this? ;)
  echo "START_SUB Sourcemage" >> $SORTED_INVENTORY
    echo "Enthrall:Generate menu:Application;SourceMage:enthrall:true:" >> $SORTED_INVENTORY
    echo "XSorcery:Sourcemage settings:Application;SourceMage:xsorcery:true:" >> $SORTED_INVENTORY
  echo "END_SUB" >> $SORTED_INVENTORY


  echo "START_SUB Other" >> $SORTED_INVENTORY
    echo "$INVENTORY" | while read line; do
      isdone="$(echo "$DONE"|grep -x "$line")"
      ! [ "$isdone" ] && ! [ -z "$line" ] && echo "$line" >> $SORTED_INVENTORY
      isdone=""
      DONE="$(echo "$DONE" ; echo "$line")"
    done
  echo "END_SUB" >> $SORTED_INVENTORY
}


function gen_all_backends() {
# Simply calls the backends for each selected wm
  for backend in $BACKENDS_AVAILABLE ; do
    echo "Working on a $backend menu"
    source $LIBENTHRALL/enthrall.$backend || echo "Failed generating $backend menu"
  done
}

function gen_all() {
# performs the requested operations and
# check if the main functions did their work
  check_own_menu &&
  scan_backends &&
  gen_inventory &&
  order_inventory &&
  gen_all_backends $BACKENDS_AVAILABLE ||
  echo "Menu generating has failed! Sorry... Perhaps we can blame ib? ;)"
}

function remove_old_menus() {
# this function removes all backups of the various menus

 MENU_LIST="$(grep "_MENU" /etc/enthrall.conf |grep -v "^#" \
            && [ -e /etc/enthrall.local.conf ] && \
            grep "_MENU" /etc/enthrall.local.conf |grep -v "^#" )"

 check_own_menu

 if [ "$OWN_MENU" == true ]; then
   echo "Removing your backup menus"
   for menu in $(echo "$MENU_LIST" | grep USER ); do
     local TARGET_MENU="$(echo "$menu" |cut -f2 -d= |sed -e 's/\"//g' -e "s#\$HOME#$HOME#" )"
     local menuname=$(basename "$TARGET_MENU")
     local basedir=$(echo "$TARGET_MENU"|sed "s/\/$menuname//")
     local TARGET_MENU_DIR="${basedir}/enthrall"
     echo -n "Removing $TARGET_MENU backups :	"
     rm -rf `eval echo $TARGET_MENU`.2* && echo "done"
     if [ -d "${TARGET_MENU_DIR}" ]; then
      echo -n "Removing $TARGET_MENU_DIR directory backups :	"
      rm -rf ${TARGET_MENU_DIR}.2* && echo "done"
     fi
   done;
 else
   echo "Removing global backup menus"
   for menu in $(echo "$MENU_LIST" | grep -v USER ); do
     local TARGET_MENU="$(echo "$menu=" |cut -f2 -d= |sed 's/\"//g' )"
     local menuname=$(basename "$TARGET_MENU")
     local basedir=$(echo "$TARGET_MENU"|sed "s/\/$menuname//")
     local TARGET_MENU_DIR="$basedir/enthrall"
     echo -n "Removing $TARGET_MENU backups :	"
     rm -rf ${TARGET_MENU}.2* && echo "done"
     if [ -d ${TARGET_MENU_DIR} ]; then
      echo -n "Removing $TARGET_MENU_DIR directory backups :	"
      rm -rf ${TARGET_MENU_DIR}.2* && echo "done"
     fi
   done;
 fi
} 

# the main part
# this is where we clean up leftovers from a previous run and
# select functionality

ARGS=$*

# fetching the list of options enthrall will use
if [ -e /etc/enthrall.conf ]; then
  . /etc/enthrall.conf
else
  echo "Hey! enthrall.conf is missing!"
  echo "Please install it"
  exit 1
fi
if [ -e /etc/enthrall.local.conf ]; then
  . /etc/enthrall.local.conf
fi


# clean up any leftovers from last enthrall
# and prepare needed files & directories
if [ -e $SORTED_INVENTORY ] ; then
  rm -f $SORTED_INVENTORY
fi

case $1 in
	--version|-v|version)
                echo "Enthrall version 0.7" ;;
	--help|-h|help)
                help_me ;;
	-inventory|-i|inventory)
                echo "The inventory will be placed in /tmp/enthrall.inventory"
	        gen_inventory
                echo "$INVENTORY" > /tmp/enthrall.inventory ;;
        -remove|-r|remove)
                remove_old_menus ;;
        *)
		gen_all $ARGS
		rm -f $SORTED_INVENTORY ;;
esac

A  => usr/share/man/man8/enthrall.8 +32 -0
@@ 1,32 @@
.TH ENTHRALL "8" "Februari 2008" "Source Mage GNU Linux" "System Administration"
.SH NAME
enthrall \- menu generating utility
.SH "DESCRIPTION"
.I enthrall
is an easy to use application for generating a menu for various windowmanagers that do not support the freedesktop.org standards.
.PP
.SH SYNOPSIS
.I enthrall [windowmanager]
.SH EXAMPLE
.SS Generate all menus
To generate a menu for all installed and supported windowmanagers, type
.I enthrall
.SS Generate one menu
To generate a menu for a single windowmanager, type
.I enthrall windowmanager
where "windowmanager" is the name of the windowmanager. So it's
.I enthrall blackbox
to generate a blackbox menu. It is possible to specify more than one windowmanager name at once.
.PP
.SH Supported windowmanagers
Currently enthrall supports the following windowmanagers, panels and popup-menu applications:
aewm, afterstep, blackbox, deskmenu, enlightenment, fbpanel, fluxbox, fvwm, fvwm-crystal, golem, icewm, idesk, ion3, jwm, kahakai, lxp-icewm, openbox, pekwm, pwm, qvwm, waimea, windowmaker, xfce4-session
.PP
.SH "AUTHOR"
Original version by Arjan Bouter
.PP
Maintained by the Source Mage GNU Linux Team (http://www.sourcemage.org)
.SH "REPORTING BUGS"
Report bugs to bugzilla <http://bugs.sourcemage.org>
.SH "WARRANTY"
This is free software with ABSOLUTELY NO WARRANTY

A  => var/lib/enthrall/README +15 -0
@@ 1,15 @@
This directory contains the backends for enthrall.
It will treat any file which starts with "enthrall." and ends
in the spell-name of the windowmanager/menu-tool as a
backend.

Take a look at the available backends to see how to build your own.

NOTE: windowmaker has 2 menu formats, the old menu and the new "plmenu"
      the default is to use the plmenu format, which is what enthrall will use.
      if you want to use the "old" format, you'll need to swap enthrall.windowmaker
      with wmaker.menu (remember to back enthrall.windowmaker).
      Before you ask, NO, I will not change enthrall to be able to build both as
      that would require too much of a rewrite. Maybe, just maybe, i'll think
      of something when all the other backends are done. Don't hold your breath...


A  => var/lib/enthrall/enthrall.aewm +80 -0
@@ 1,80 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$AEWM_USER_MENU" ] &&
    mv $AEWM_USER_MENU $AEWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    AEWMMENU="$AEWM_USER_MENU"
  else
    [ -e "$AEWM_MENU" ] &&
    mv $AEWM_MENU $AEWM_MENU.$(date +%Y%m%d%H%M%S)
    AEWMMENU="$AEWM_MENU"
  fi

  local menuname=`basename "$AEWMMENU"`
  local menudir=`echo "$AEWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_aewmmenu {
# the start of the aewm menu
cat >> $AEWMMENU << EOF
# Warning, this file is automatically generated
# DO NOT EDIT
#
# Start of the aewm menu
EOF
}

function close_aewmmenu {
# closing the aewm menu
cat >> $AEWMMENU << EOF
   menu "aewm"
   cmd "aepanel" "aepanel"
   cmd "Kill aepanel" "skill aepanel"
   cmd "Logout" "skill aesession"
   end

   # End of the aewm menu" >> $AEWMMENU
EOF
}

function insert_submenu_begin() {
  echo "menu \"$1\" ">> $AEWMMENU
}

function insert_submenu_end {
  echo "end" >> $AEWMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `

    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "cmd \"$APP\" \"xterm -e $EXEC\" " >> $AEWMMENU
    else
      echo "cmd \"$APP\" \"$EXEC\" " >> $AEWMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_aewmmenu &&
build_menu &&
close_aewmmenu ||
echo "Generating of the aewm menu has failed!"

A  => var/lib/enthrall/enthrall.afterstep +152 -0
@@ 1,152 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    AFTERSTEPMENU="$AFTERSTEP_USER_MENU"
  else
    AFTERSTEPMENU="$AFTERSTEP_MENU"
  fi

  [ -d "$AFTERSTEPMENU" ] &&
  mv $AFTERSTEPMENU $AFTERSTEPMENU.$(date +%Y%m%d%H%M%S)

  mkdir $AFTERSTEPMENU &&
  cd $AFTERSTEPMENU
}

function close_afterstep_menu {
# closing the afterstep menu
  SUB_COUNT="$(find . -type d -name "??_*"|sort|tail -n1|cut -f2 -d/ |cut -f1 -d_ )"
  let SUB_COUNT=SUB_COUNT+1          &&
  echo "Nop \"\"" > ${SUB_COUNT}_nop &&
  let SUB_COUNT=SUB_COUNT+1          &&
  mkdir ${SUB_COUNT}_Afterstep       &&
  cd ${SUB_COUNT}_Afterstep          &&
  cat << EOF >> 0_Whats_New
Exec "Whats new in version 2.0?" exec konqueror http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec firefox http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec mozilla http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec dillo http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec opera http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec xterm -e lynx http://afterstep.sf.net/index.php &
Exec "Whats new in version 2.0?" exec xterm -e links http://afterstep.sf.net/index.php &
EOF
  cat << EOF >> 1_libAfterImage
Exec "libAfterImage" exec konqueror http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec firefox http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec mozilla http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec dillo http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec opera http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec xterm -e lynx http://afterstep.sf.net/afterimage/ &
Exec "libAfterImage" exec xterm -e links http://afterstep.sf.net/afterimage/ &
EOF
  cat << EOF >> 2_International_Text
Exec "International text support" exec  firefox http://afterstep.sf.net/afterimage/
Exec "International text support" exec  mozilla http://afterstep.sf.net/afterimage/
Exec "International text support" exec  konqueror http://afterstep.sf.net/afterimage/
Exec "International text support" exec  opera http://afterstep.sf.net/afterimage/
Exec "International text support" exec  dillo http://afterstep.sf.net/afterimage/
Exec "International text support" exec  xterm -e links http://afterstep.sf.net/afterimage/
Exec "International text support" exec  xterm -e lynx http://afterstep.sf.net/afterimage/
EOF
  cat << EOF >> 3_XML_images
Exec "XML images" exec firefox http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec mozilla http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec konqueror http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec dillo http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec opera http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec xterm -e links http://afterstep.sf.net/asxmlimages.php &
Exec "XML images" exec xterm -e lynx http://afterstep.sf.net/asxmlimages.php &
EOF
  cat << EOF >> 4_Color_Schemes
Exec "Color Schemes" exec firefox http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec konqueror http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec mozilla http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec dillo http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec opera http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec xterm -e lynx http://afterstep.sf.net/afterstep20beta/ &
Exec "Color Schemes" exec xterm -e links http://afterstep.sf.net/afterstep20beta/ &
EOF
  cat << EOF >> 5_Supported_Standards
Exec "Supported standards" exec firefox http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec konqueror http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec mozilla http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec dillo http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec opera http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec xterm -e lynx http://www.freedesktop.org/standards/wm-spec/ &
Exec "Supported standards" exec xterm -e links http://www.freedesktop.org/standards/wm-spec/ &
EOF
  cat << EOF >> 6_afterstepdoc
Exec "AfterStep documentation" exec afterstepdoc &
MiniPixmap "mini-as.xpm"
EOF
  echo "Nop \"\"" > 7_nop &&
  mkdir 8_Quit            &&
  cd 8_Quit               &&
  cat << EOF >> 0_close
Quit "Close this session"
MiniPixmap "mini-exit.xpm"
EOF
  cat << EOF >> 1_exit
Nop "Exit ?" Form QuitForm
MiniPixmap "mini-exit.xpm"
EOF
  cat << EOF >> 2_restartsession
Restart "Restart this session" afterstep -r
EOF
   cd ../..
}

function insert_submenu_begin() {
  mkdir ${SUB_COUNT}_${1} &&
  cd ${SUB_COUNT}_${1}
}

function insert_submenu_end {
  cd ..
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    local exec_command="$(echo $EXEC|cut -f1 -d" ")"
    if (echo exec_command |grep -v -q / ); then
      local which_exec="$(which $exec_command)"
      EXEC="$(echo $EXEC|sed "s#$exec_command#$which_exec#" )"
    fi
    TERM=`echo $menuline|cut -f5 -d":" `
    NAME=$(echo $APP|sed 's/ //g')
    if [[ $TERM == true ]] ; then
      cat << EOF >> ${item_count}_${NAME}
        Exec "$APP" exec xterm -e ${EXEC} &
EOF
    else
      cat << EOF >> ${item_count}_${NAME}
        Exec "$APP" exec ${EXEC} &
EOF
    fi
}

function build_menu {
  local item_count=0
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin $(echo $line|cut -f2 -d" " )
		    item_count=0
		    let SUB_COUNT=SUB_COUNT+1 ;;
        END_SUB) insert_submenu_end ;;
        *) insert_entry "$line"
           let item_count=item_count+1 ;;
    esac
  done
}

# building the menu
SUB_COUNT="0"
prepare_menu_location &&
build_menu &&
close_afterstep_menu ||
echo "Generating of the afterstep menu has failed"

A  => var/lib/enthrall/enthrall.blackbox +89 -0
@@ 1,89 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$BLACKBOX_USER_MENU" ] &&
    mv $BLACKBOX_USER_MENU $BLACKBOX_USER_MENU.$(date +%Y%m%d%H%M%S)
    BBOXMENU="$BLACKBOX_USER_MENU"
  else
    [ -e "$BLACKBOX_MENU" ] &&
    mv $BLACKBOX_MENU $BLACKBOX_MENU.$(date +%Y%m%d%H%M%S)
    BBOXMENU="$BLACKBOX_MENU"
  fi

  local menuname=`basename "$BBOXMENU"`
  local menudir=`echo "$BBOXMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_bbmenu {
# the start of the blackbox menu
cat >> $BBOXMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the blackbox menu

  [begin] (Blackbox)
EOF
}

function close_bbmenu {
# closing the blackbox menu
cat >> $BBOXMENU << EOF
    [submenu] (BlackBox)
      [submenu] (Styles)
        [stylesdir] (/usr/share/blackbox/styles)
        [stylesdir] (/usr/share/commonbox/styles)
        [stylesdir] (~/.blackbox/styles)
      [end]
      [workspaces] (Workspace List)
      [config] (Configuration)
      [reconfig] (Reconfigure)
      [restart] (Restart)
      [exit] (Exit)
    [end]
  [end]

  # End of the blackbox menu
EOF
}

function insert_submenu_begin() {
  echo "[submenu] ($1)" >> $BBOXMENU
}

function insert_submenu_end {
  echo "[end]" >> $BBOXMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "[exec] ("$APP") {xterm -e $EXEC}" >> $BBOXMENU
    else
      echo "[exec] ("$APP") {$EXEC}" >> $BBOXMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_bbmenu &&
build_menu &&
close_bbmenu ||
echo "Generating of the blackbox menu has failed!"

A  => var/lib/enthrall/enthrall.deskmenu +74 -0
@@ 1,74 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$DESKMENU_USER_MENU" ] &&
    mv $DESKMENU_USER_MENU $DESKMENU_USER_MENU.$(date +%Y%m%d%H%M%S)
    DESKMENU="$DESKMENU_USER_MENU"
  else
    [ -e "$DESKMENU_MENU" ] &&
    mv $DESKMENU_MENU $DESKMENU_MENU.$(date +%Y%m%d%H%M%S)
    DESKMENU="$DESKMENU_MENU"
  fi

  local menuname=`basename "$DESKMENU"`
  local menudir=`echo "$DESKMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_deskmenu {
# the start of the DESKMENU menu
cat >> $DESKMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the DESKMENU menu

EOF
}

function close_deskmenu {
# closing the DESKMENU menu
cat >> $DESKMENU << EOF
  # End of the DESKMENU menu
EOF
}

function insert_submenu_begin() {
  echo "submenu=$1" >> $DESKMENU
}

function insert_submenu_end {
  echo "endmenu=" >> $DESKMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "menuitem=${APP}:xterm -e $EXEC}" >> $DESKMENU
    else
      echo "menuitem=${APP}:${EXEC}" >> $DESKMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_deskmenu &&
build_menu &&
close_deskmenu ||
echo "Generating of the deskmenu menu has failed!"

A  => var/lib/enthrall/enthrall.dmenu +67 -0
@@ 1,67 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$DMENU_USER_MENU" ] &&
    mv $DMENU_USER_MENU $DMENU_USER_MENU.$(date +%Y%m%d%H%M%S)
    DMENU="$DMENU_USER_MENU"
  else
    [ -e "$DMENU_MENU" ] &&
    mv $DMENU_MENU $DMENU_MENU.$(date +%Y%m%d%H%M%S)
    DMENU="$DMENU_MENU"
  fi

  local menuname=`basename "$DMENU"`
  local menudir=`echo "$DMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_dmenu {
# the start of the DMENU menu
cat >> $DMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the DMENU menu

EOF
}

function close_dmenu {
# closing the DMENU menu
cat >> $DMENU << EOF
  # End of the DMENU menu
EOF
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "xterm -e ${EXEC}" >> $DMENU
    else
      echo "${EXEC}" >> $DMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) true ;;
	END_SUB) true ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_dmenu &&
build_menu &&
close_dmenu ||
echo "Generating of the dmenu menu has failed!"


A  => var/lib/enthrall/enthrall.enlightenment +86 -0
@@ 1,86 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    ENLIGHTENMENTMENU="$ENLIGHTENMENT_USER_MENU"
  else
    ENLIGHTENMENTMENU="$ENLIGHTENMENT_MENU"
  fi

  local menuname=`basename "$ENLIGHTENMENTMENU"`
  local menudir=`echo "$ENLIGHTENMENTMENU"|sed "s/\/$menuname//"`

  [ -d "$menudir" ] && mv $menudir $menudir.$(date +%Y%m%d%H%M%S)
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_enlightenmentmenu {
# the start of the enlightenment menu
cat >> $ENLIGHTENMENTMENU << EOF
# Warning, this file is automatically generated
# DO NOT EDIT
#
"Enlightenment" "ROOT"
EOF
}

function close_enlightenmentmenu {
# closing the enlightenment menu
cat >> $ENLIGHTENMENTMENU << EOF
"Desktop"               NULL menu desktop.menu
"Settings"              NULL menu settings.menu
"Themes"                NULL menu themes
"Maintenance"           NULL menu maintenance.menu
"Help"                  NULL exec "edox $EROOT/E-docs"
"About Enlightenment"   NULL about
"About this theme"      NULL exec "edox $ETHEME/ABOUT"
"Restart"               NULL "exit restart"
"Log Out"               NULL "exit logout"

# End of the enlightenment menu >> $ENLIGHTENMENTMENU
EOF
}

function insert_submenu_begin() {
  CURRENT_MENU=$1
  echo "\"$1\" NULL menu $(basename ${ENLIGHTENMENTMENU})_${1}.menu">> $ENLIGHTENMENTMENU
  echo "\"$1\"" >> ${ENLIGHTENMENTMENU}_${1}.menu
}

function insert_submenu_end {
  CURRENT_MENU=''
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    ICON=`echo $menuline|cut -f6 -d":" `

    if [[ $TERM == true ]] ; then
      echo "\"$APP\" \"$ICON\" exec \"xterm -e $EXEC\" " >> ${ENLIGHTENMENTMENU}_${CURRENT_MENU}.menu
    else
      echo "\"$APP\" \"$ICON\" exec \"$EXEC\" " >> ${ENLIGHTENMENTMENU}_${CURRENT_MENU}.menu
    fi
}

function build_menu {
  cd $menudir
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d' ' ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_enlightenmentmenu &&
build_menu &&
close_enlightenmentmenu ||
echo "Generating of the enlightenment menu has failed!"

A  => var/lib/enthrall/enthrall.fbpanel +102 -0
@@ 1,102 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$FBPANEL_USER_MENU" ] &&
    mv $FBPANEL_USER_MENU $FBPANEL_USER_MENU.$(date +%Y%m%d%H%M%S)
    FBMENU="$FBPANEL_USER_MENU"
  else
    [ -e "$FBPANEL_MENU" ] &&
    mv $FBPANEL_MENU $FBPANEL_MENU.$(date +%Y%m%d%H%M%S)
    FBMENU="$FBPANEL_MENU"
  fi

  local menuname=`basename "$FBMENU"`
  local menudir=`echo "$FBMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_fbmenu {
# the start of the fbpanel menu
cat >> $FBMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the fbpanel menu

EOF
}

function close_fbmenu {
# closing the fbpanel menu
cat >> $FBMENU << EOF
separator {
}
item {
    name = configure
    image = /usr/share/fbpanel/images/gnome-setting.svg
    command = configure
}

# End of the fbpanel menu
EOF
}

function insert_submenu_begin() {
cat >> $FBMENU << EOF
    menu {
       name = $1
       image = /usr/share/fbpanel/images/file-manager.svg
EOF
}

function insert_submenu_end {
  echo "    }" >> $FBMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    ICON=`echo $menuline|cut -f6 -d":" `
    if [ -z ${ICON} ]; then
            ICON="/usr/share/fbpanel/images/gnome_terminal.svg"
    fi
    if [[ $TERM == true ]] ; then
    cat >> $FBMENU << EOF
    item {
        name = $APP
        image = $ICON
        command = xterm -e $EXEC
    }
EOF
    else
    cat >> $FBMENU << EOF
    item {
        name = $APP
        image = $ICON
        command = $EXEC
    }
EOF
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_fbmenu &&
build_menu &&
close_fbmenu ||
echo "Generating of the fbpanel menu has failed!"

A  => var/lib/enthrall/enthrall.fluxbox +106 -0
@@ 1,106 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$FLUXBOX_USER_MENU" ] &&
    mv $FLUXBOX_USER_MENU $FLUXBOX_USER_MENU.$(date +%Y%m%d%H%M%S)
    FLUXMENU="$FLUXBOX_USER_MENU"
  else
    [ -e "$FLUXBOX_MENU" ] &&
    mv $FLUXBOX_MENU $FLUXBOX_MENU.$(date +%Y%m%d%H%M%S)
    FLUXMENU="$FLUXBOX_MENU"
  fi

  local menuname=`basename "$FLUXMENU"`
  local menudir=`echo "$FLUXMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_fbmenu {
# the start of the fluxbox menu
cat >> $FLUXMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the fluxbox menu

  [begin] (fluxbox)
EOF
}

function close_fbmenu {
# closing the fluxbox menu
cat >> $FLUXMENU << EOF
  [submenu] (fluxbox menu)
        [config] (Configure)
  [submenu] (System Styles) {Choose a style...}
        [stylesdir] (/usr/share/fluxbox/styles)
        [stylesdir] (/usr/share/commonbox/styles/)
        [stylesdir] (\$HOME/fluxbox/styles)
  [end]
  [submenu] (User Styles) {Choose a style...}
        [stylesdir] (~/.fluxbox/styles)
  [end]
        [workspaces]   (Workspace List)
  [submenu] (Tools)
        [exec] (Window name) {xprop WM_CLASS|cut -d \" -f 2|xmessage -file - -center}
        [exec] (Screenshot) {import screenshot.png && qiv -W 50 screenshot.png}
        [exec] (gtk-theme-switch) {switch}
  [end]
  [submenu] (Window)
        [restart] (fvwm) {fvwm}
        [restart] (openbox) {openbox}
        [restart] (waimea) {waimea}
        [restart] (windowmaker) {wmaker}
  [end]
        [exec] (Lock screen) {xlock}
        [commanddialog] (Fluxbox Command)
        [reconfig] (Reload config)
        [restart] (Restart)
        [separator]
        [exit] (Exit)
  [end]
  [end]

  # End of the fluxbox menu
EOF
}

function insert_submenu_begin() {
  echo "[submenu] ($1)" >> $FLUXMENU
}

function insert_submenu_end {
  echo "[end]" >> $FLUXMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "[exec] ("$APP") {xterm -e $EXEC}" >> $FLUXMENU
    else
      echo "[exec] ("$APP") {$EXEC}" >> $FLUXMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_fbmenu &&
build_menu &&
close_fbmenu ||
echo "Generating of the fluxbox menu has failed!"

A  => var/lib/enthrall/enthrall.fvwm +76 -0
@@ 1,76 @@
#!/bin/sh

CURRENT_SUBMENU=""

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$FVWM_USER_MENU" ] &&
    mv $FVWM_USER_MENU $FVWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    FVWMMENU="$FVWM_USER_MENU"
  else
    [ -e "$FVWM_MENU" ] &&
    mv $FVWM_MENU $FVWM_MENU.$(date +%Y%m%d%H%M%S)
    FVWMMENU="$FVWM_MENU"
  fi

  local menuname=`basename "$FVWMMENU"`
  local menudir=`echo "$FVWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function insert_submenu_begin {
	CURRENT_SUBMENU=$1
cat >> $FVWMMENU << EOF
AddToMenu SourceMage ${CURRENT_SUBMENU} Popup SourceMage.${CURRENT_SUBMENU}
AddToMenu SourceMage.${CURRENT_SUBMENU} "${CURRENT_SUBMENU}" Title top
EOF
}

function insert_submenu_end {
	CURRENT_SUBMENU=""
}

function insert_entry {
	menuline=$1
	APP=`echo $menuline |cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
	ICON=`echo $menuline|cut -f6 -d":" `
	if [ ! -z ${ICON} ]; then
		ICON="%${ICON}%"
	fi
	if [[ ${TERM} == true ]] ; then
		echo "AddToMenu SourceMage.${CURRENT_SUBMENU} \"${ICON}${APP}\" Exec exec xterm -fg white -bg black -e $EXEC" >> ${FVWMMENU}
	else
		echo "AddToMenu SourceMage.${CURRENT_SUBMENU} \"${ICON}${APP}\" Exec exec $EXEC" >> ${FVWMMENU}
	fi
}

function start_fvwm_menu {
cat >> $FVWMMENU << EOF
#
#
# Do not edit this file. It will be overwritten by enthrall.
#
#

ImagePath +:/usr/share/pixmaps
AddToMenu SourceMage "Applications" Title top
EOF
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
		END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}
prepare_menu_location &&
start_fvwm_menu &&
build_menu ||
echo "Generating of the fvwm menu has failed!"

A  => var/lib/enthrall/enthrall.fvwm-crystal +72 -0
@@ 1,72 @@
#!/bin/sh

function prepare_menu_location {

# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    FVWMCRYSTALMENU="$FVWM_CRYSTAL_USER_MENU"
  else
    FVWMCRYSTALMENU="$FVWM_CRYSTAL_MENU"
  fi

  [ -d "$FVWMCRYSTALMENU" ] &&
  mv $FVWMCRYSTALMENU $FVWMCRYSTALMENU.$(date +%Y%m%d%H%M%S)

  mkdir -p $FVWMCRYSTALMENU &&
  cd $FVWMCRYSTALMENU
}

function close_fvwmcrystal_menu {
# closing the fvwmcrystal menu
true
}

function insert_submenu_begin() {
  mkdir ${1} &&
  cd ${1}
}

function insert_submenu_end {
  cd ..
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    local exec_command="$(echo $EXEC|cut -f1 -d" ")"
    if (echo exec_command |grep -v -q / ); then
      local which_exec="$(which $exec_command)"
      EXEC="$(echo $EXEC|sed "s#$exec_command#$which_exec#" )"
    fi
    TERM=`echo $menuline|cut -f5 -d":" `
    NAME=$(echo $APP|sed 's/ //g')
    if [[ $TERM == true ]] ; then
      cat << EOF > ${NAME}
#!/bin/sh
exec xterm -e ${EXEC} \$@
EOF
    else
      cat << EOF > ${NAME}
#!/bin/sh
exec ${EXEC} \$@
EOF
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin $(echo $line|cut -f2 -d" " );;
        END_SUB) insert_submenu_end ;;
        *) insert_entry "$line"
    esac
  done
}

# building the menu
prepare_menu_location &&
build_menu &&
close_fvwmcrystal_menu ||
echo "Generating of the fvwm-crystal menu has failed"

A  => var/lib/enthrall/enthrall.golem +87 -0
@@ 1,87 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$GOLEM_USER_MENU" ] &&
    mv $GOLEM_USER_MENU $GOLEM_USER_MENU.$(date +%Y%m%d%H%M%S)
    GOLEMMENU="$GOLEM_USER_MENU"
  else
    [ -e "$GOLEM_MENU" ] &&
    mv $GOLEM_MENU $GOLEM_MENU.$(date +%Y%m%d%H%M%S)
    GOLEMMENU="$GOLEM_MENU"
  fi

  local menuname=`basename "$GOLEMMENU"`
  local menudir=`echo "$GOLEMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_golemmenu {
# the start of the golem menu
cat >> $GOLEMMENU << EOF
  # Warning, this file is automatically generated"
  # DO NOT EDIT
  #
  # Start of the golem menus

  load "simple_menus" {
  	param "menu_stacklayer"	"top";	# where menus go in the stacking layer
  	param "menu_button"	"3";	# button to open root menu

  	param "rootmenu" "Title" {

EOF
}

function close_golemmenu {
# closing the golem menu
cat >> $GOLEMMENU << EOF
   param "submenu" "Golem" {
   	param "restart" "Restart";
   		param "abort" "Abort";
   		param "exit" "Exit";
   	}
   }
   }

EOF
}

function insert_submenu_begin() {
  echo "param \"submenu\" \"$1\" {" >> $GOLEMMENU
}

function insert_submenu_end {
   echo "}" >> $GOLEMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "	param \"command\" \"$APP\"	{ param \"dat\" \"exec xterm -name $APP -e $EXEC\"; }" >> $GOLEMMENU
    else
      echo "	param \"command\" \"$APP\"	{ param \"dat\" \"exec $EXEC\"; }" >> $GOLEMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_golemmenu &&
build_menu &&
close_golemmenu ||
echo "Generating of the golem menu has failed!"

A  => var/lib/enthrall/enthrall.icewm +74 -0
@@ 1,74 @@
#!/bin/sh

function prepare_menu_location {
# checking which menu to build
  if [ "$OWN_MENU" == "true" ]; then
    ICEWMMENU="$ICEWM_USER_MENU"
  else
    ICEWMMENU="$ICEWM_MENU"
  fi

# figuring out where to put the menu files
  local menuname=`basename "$ICEWMMENU"`
  local menudir=`echo "$ICEWMMENU"|sed "s/\/$menuname//"`

# moving the old menu out of the way
    if [ -f $ICEWMMENU ]; then
      mv $ICEWMMENU $ICEWMMENU.$(date +%Y%m%d%H%M%S)
    fi
    if [ -d $menudir/enthrall ]; then
      mv $menudir/enthrall $menudir/enthrall.$(date +%Y%m%d%H%M%S)
    fi

# preparing the menu dir
  [ -d "$menudir/enthrall" ] || mkdir -p $menudir/enthrall
  cd $menudir
}

function start_icewm_menu {
# the start of the icewm menu
cat >> $ICEWMMENU << EOF
# Warning, this file is automatically generated by enthrall
# DO NOT EDIT

# entry to get the toolbar buttons into the menu
menufile Tool_bar folder toolbar
EOF
}

function insert_submenu_begin() {
  echo "menufile $1 folder enthrall/$1" >> $ICEWMMENU
}

function insert_entry() {
    menuline=$1
    local menuname=$(basename $ICEWMMENU)
    local menudir=$(echo "$ICEWMMENU"|sed "s/\/$menuname//")
    APP=$(echo $menuline|cut -f1 -d":" )
    EXEC=$(echo $menuline|cut -f4 -d":" )
    TERM=$(echo $menuline|cut -f5 -d":" )
    ICON=$(echo $menuline|cut -f6 -d":" )
    [ -z ${ICON} ] && ICON="default.png"
    if [[ $TERM == true ]] ; then
      echo "prog \"${APP}\" ${ICON} xterm -e ${EXEC}" >> $menudir/enthrall/$ICESUBMENU
    else
      echo "prog \"${APP}\" ${ICON} ${EXEC}" >> $menudir/enthrall/$ICESUBMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) ICESUBMENU="$(echo $line|cut -f2 -d" " )"
                    insert_submenu_begin $ICESUBMENU ;;
	END_SUB) true;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_icewm_menu &&
build_menu ||
echo "Generating of the icewm menu has failed!"

A  => var/lib/enthrall/enthrall.idesk +78 -0
@@ 1,78 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$IDESK_USER_MENU" ] &&
    mv $IDESK_USER_MENU $IDESK_USER_MENU.$(date +%Y%m%d%H%M%S)
    [ -d "${IDESK_USER_MENU}" ] || mkdir -p "${IDESK_USER_MENU}"
    IDESKMENU="$IDESK_USER_MENU"
  else
    [ -e "$IDESK_MENU" ] &&
    mv $IDESK_MENU $IDESK_MENU.$(date +%Y%m%d%H%M%S)
  fi
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    ICON=`echo $menuline|cut -f6 -d":" `
    if [ -z ${ICON} ]; then
      ICON="rxvt.png"
    fi
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      cat >> ${IDESKMENU}/${APP}.lnk << EOF
table Icon
  Caption: $APP
  Command: xterm -c \"$EXEC\"
  Icon: $ICON
  Width: 48
  Heigth: 48
  X: 30
  Y: 30
end
EOF
    else cat >> ${IDESKMENU}/${APP}.lnk << EOF
table Icon
  Caption: $APP
  Command: \"$EXEC\"
  Icon: $ICON
  Width: 48
  Heigth: 48
  X: 30
  Y: 30
end
EOF
    fi
}

function build_menu {
if [ "$OWN_MENU" == "true" ]; then
    case $line in
        START_SUB*) true ;;
        END_SUB) true ;;
        *) insert_entry "$line" ;;
    esac
else
cat >> $IDESK_MENU << EOF
table Icon
  Caption: Idesk
  Command: /usr/bin/Xdialog --msgbox "IDESK -- run Enthrall as a regular user to generate icons" 15 30 
  Icon: /usr/share/idesk/folder_home.xpm
  Width: 48
  Height: 48
  X: 30
  Y: 30
end
EOF
    return 0
fi
}

# building the menu
prepare_menu_location &&
build_menu ||
echo "Generating of the idesk menu has failed!"

A  => var/lib/enthrall/enthrall.ion3 +131 -0
@@ 1,131 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$ION_USER_MENU" ] &&
    mv $ION_USER_MENU $ION_USER_MENU.$(date +%Y%m%d%H%M%S)
    IONMENU="$ION_USER_MENU"
  else
    [ -e "$ION_MENU" ] &&
    mv $ION_MENU $ION_MENU.$(date +%Y%m%d%H%M%S)
    IONMENU="$ION_MENU"
  fi

  local menuname=`basename "$IONMENU"`
  local menudir=`echo "$IONMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_ion_menu {
# the start of the ion menu
cat >> $IONMENU << EOF
-- Warning, this file is automatically generated
-- DO NOT EDIT
--
-- Start of the ion menu

--
-- Ion menu definitions
--

-- Main menu
  defmenu("mainmenu", {
    submenu("Programs",         "appmenu"),
    menuentry("Run...",         "mod_query.query_exec(_)"),
    submenu("Ion",              "ion"),
})

EOF
}

function build_appmenu() {
# ion dropped inline submenus, so we have to generate an index... :(
  local menu=""
  echo "defmenu(\"appmenu\", {" >> $IONMENU
  for menu in $(grep "START_SUB" $SORTED_INVENTORY| cut -f2 -d" " ); do
    local menuname="$( echo "$menu" | tr [A-Z] [a-z] )"
    [ -n $menu ] && [ -n $menuname ] &&
    echo "    submenu(\"$menu\",      \"$menuname\")," >> $IONMENU
  done
  echo "})" >> $IONMENU
  echo "" >> $IONMENU
}

function close_ion_menu() {
# closing the ion menu
cat >> $IONMENU << EOF
  
defmenu("ion", {
    menuentry("Help",      "mod_query.query_man(_)"),
    menuentry("About Ion", "mod_query.show_about_ion(_)"),
    submenu("Styles",      "stylemenu"),
    submenu("Session",     "sessionmenu"),
})

-- Session control menu
defmenu("sessionmenu", {
    menuentry("Save",           "ioncore.snapshot()"),
    menuentry("Restart",        "ioncore.restart()"),
    menuentry("Exit",           "ioncore.shutdown()"),
})

-- Context menu (frame/client window actions)
defctxmenu("WFrame", {
    menuentry("Close",          "WRegion.rqclose_propagate(_, _sub)"),
    menuentry("Kill",           "WClientWin.kill(_sub)",
                                "_sub:WClientWin"),
    menuentry("(Un)tag",        "WRegion.toggle_tag(_sub)",
                                "_sub:non-nil"),
    menuentry("Attach tagged",  "WFrame.attach_tagged(_)"),
    menuentry("Clear tags",     "ioncore.clear_tags()"),
    menuentry("Window info",    "mod_query.show_clientwin(_, _sub)",
                                "_sub:WClientWin"),
})


-- End of the ion menu
  
EOF
}

function insert_submenu_begin() {
  local menuname="$(echo "$1" | tr [A-Z] [a-z] )"
  echo "defmenu(\"$menuname\",  {" >>$IONMENU
}

function insert_submenu_end {
  echo "})" >>$IONMENU
  echo "" >> $IONMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "    menuentry(\"$APP\", \"ioncore.exec_on(_, 'xterm -e $EXEC')\")," >>$IONMENU
    else
      echo "    menuentry(\"$APP\", \"ioncore.exec_on(_, '$EXEC')\")," >>$IONMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_ion_menu &&
build_appmenu &&
build_menu &&
close_ion_menu ||
echo "Generating of the ion menu has failed!"

A  => var/lib/enthrall/enthrall.jwm +83 -0
@@ 1,83 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$JWM_USER_MENU" ] &&
    mv $JWM_USER_MENU $JWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    JWMMENU="$JWM_USER_MENU"
  else
    [ -e "$JWM_MENU" ] &&
    mv $JWM_MENU $JWM_MENU.$(date +%Y%m%d%H%M%S)
    JWMMENU="$JWM_MENU"
  fi

  local menuname=`basename "$JWMMENU"`
  local menudir=`echo "$JWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_jwm_menu {
# the start of the jwm menu
cat >> $JWMMENU << EOF
<JWM>
<!-- The root menu, if this is undefined you will not get a menu. -->
<!-- Additional RootMenu attributes: onroot, labeled, label -->
<!-- WARNING: this menu is generated by enthrall, do not edit manually. -->
<RootMenu height="32" onroot="123">
<Menu icon="folder.png" label="Applications">
EOF
}

function close_jwm_menu {
# closing the jwm menu
cat >> $JWMMENU << EOF
</Menu>
<Separator/>
<Restart label="Restart" icon="restart.png"/>
<Exit label="Exit" confirm="true" icon="exit.png"/>
</RootMenu>
EOF
}

function insert_submenu_begin() {
  echo "<Menu icon=\"folder.png\" label=\"$1\">" >> $JWMMENU
}

function insert_submenu_end {
  echo "</Menu>" >>$JWMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    ICON=`echo $menuline|cut -f6 -d":" `
    if [ -z ${ICON} ]; then
      ICON="rxvt.png"
    fi
    if [[ $TERM == true ]] ; then
      echo "<Program icon=\"$ICON\" label=\"$APP\">xterm -e $EXEC</Program>" >>$JWMMENU
    else
      echo "<Program icon=\"$ICON\" label=\"$APP\">$EXEC</Program>" >>$JWMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_jwm_menu &&
build_menu &&
close_jwm_menu ||
echo "Generating of the jwm menu has failed!"

A  => var/lib/enthrall/enthrall.kahakai +117 -0
@@ 1,117 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$KAHAKAI_USER_MENU" ] &&
    mv $KAHAKAI_USER_MENU $KAHAKAI_USER_MENU.$(date +%Y%m%d%H%M%S)
    KKMENU="$KAHAKAI_USER_MENU"
  else
    [ -e "$KAHAKAI_MENU" ] &&
    mv $KAHAKAI_MENU $KAHAKAI_MENU.$(date +%Y%m%d%H%M%S)
    KKMENU="$KAHAKAI_MENU"
  fi

  local menuname=`basename "$KKMENU"`
  local menudir=`echo "$KKMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_kkmenu {
# the start of the kahakai menu
cat >> $KKMENU << EOF
!
! Warning, this file is automatically generated
! DO NOT EDIT
!
! Start of the kahakai root menu
!
[start] (rootmenu)
  [title] (Kahakai)
EOF
}

function close_kkmenu {
cat >> $KKMENU << EOF
  [sub] (Desktops) <__gotodesktoplist__>

  [sub] (Styles)        <!styles.py>

  [sub] (Proclist)      <!procinfo.pl>

  [restart] (Restart)
  [exit]    (Exit)
[end]

!
! Window Menu
!
[start] (window)
  [title]   (\\n)
  [submenu] (Settings)
    [checkbox=MAXIMIZED]      @FALSE (Maximized)        "maximize"         @TRUE (Maximized)        "unMaximize"
    [checkbox=MINIMIZED]      @FALSE (Minimized)        "minimize"         @TRUE (Minimized)        "unMinimize"
    [checkbox=FULLSCREEN]     @FALSE (Fullscreen)       "fullscreenOn"     @TRUE (Fullscreen)       "fullscreenOff"
    [checkbox=SHADED]         @FALSE (Shaded)           "shade"            @TRUE (Shaded)           "unShade"
    [checkbox=STICKY]         @FALSE (Sticky)           "sticky"           @TRUE (Sticky)           "unSticky"
    [checkbox=ALWAYSONTOP]    @FALSE (Always on top)    "alwaysOnTopOn"    @TRUE (Always on top)    "alwaysOnTopOff"
    [checkbox=ALWAYSATBOTTOM] @FALSE (Always at bottom) "alwaysAtBottomOn" @TRUE (Always at bottom) "alwaysAtBottomOff"
    [checkbox=DECORTITLE]     @FALSE (Titlebar)         "decorTitleOn"     @TRUE (Titlebar)         "decorTitleOff"
    [checkbox=DECORHANDLE]    @FALSE (Handlebar)        "decorHandleOn"    @TRUE (Handlebar)        "decorHandleOff"
    [checkbox=DECORBORDER]    @FALSE (Border)           "decorBorderOn"    @TRUE (Border)           "decorBorderOff"
    [checkbox=DECORALL]       @FALSE (All decorations)  "decorAllOn"       @TRUE (All decorations)  "decorAllOff"
  [end]
  [sub]     (Process info) <!procinfo.pl -host \h -pid \p>
  [submenu] (Desktop functions)
    [sub]  (Send to desktop) <__senddesktoplist__>
    [sub]  (Join desktop)    <__joindesktoplist__>
    [sub]  (Part desktop)    <__partdesktoplist__>
    [item] (Join all)     "joinAllDesktops"
    [item] (Part all)     "partAllDesktopsExceptCurrent"
    [item] (Part current) "partCurrentDesktop"
  [end]
  [item]    (Raise)       "raise"
  [item]    (Lower)       "lower"
  [item]    (Kill client) "kill"
  [item]    (Close)       "close"
[end]
EOF
}

function insert_submenu_begin() {
  echo "[submenu] ($1)" >> $KKMENU
}

function insert_submenu_end {
  echo "[end]" >> $KKMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "[item] ("$APP") {xterm -e $EXEC}" >> $KKMENU
    else
      echo "[item] ("$APP") {$EXEC}" >> $KKMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
        END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_kkmenu &&
build_menu &&
close_kkmenu ||
echo "Generating of the kahakai menu has failed!"

A  => var/lib/enthrall/enthrall.lxde +96 -0
@@ 1,96 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$LXDE_USER_MENU" ] &&
    mv $LXDE_USER_MENU $LXDE_USER_MENU.$(date +%Y%m%d%H%M%S)
    LXDEMENU="$LXDE_USER_MENU"
  else
    [ -e "$LXDE_MENU" ] &&
    mv $LXDE_MENU $LXDE_MENU.$(date +%Y%m%d%H%M%S)
    LXDEMENU="$LXDE_MENU"
  fi

  local menuname=`basename "$LXDEMENU"`
  local menudir=`echo "$LXDEMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_lxde_menu {
# the start of the lxde menu
cat >> $LXDEMENU << EOF
<?xml version="1.0" encoding="UTF-8"?>
<lxde_menu xmlns="http://lxde.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://lxde.org/
  file:///usr/share/lxde/menu.xsd">
  
<menu id="root-menu" label="Lxde">
EOF
}

function close_lxde_menu {
# closing the lxde menu
cat >> $LXDEMENU << EOF
    <separator />
    <menu id="lxde-menu" label="Lxde">
      <item label="ObConf">
        <action name="Execute"><execute>obconf</execute></action>
      </item>
      <item label="Reconfigure">
        <action name="Reconfigure" />
      </item>
      <separator />
      <item label="Exit">
        <action name="Exit" />
      </item>
    </menu>
  </menu>
  
  </lxde_menu>
  
EOF
}

function insert_submenu_begin() {
  echo "<menu id=\"$1\" label=\"$1\">" >> $LXDEMENU
}

function insert_submenu_end {
  echo "</menu>" >>$LXDEMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "  <item label=\"$APP\">" >>$LXDEMENU
      echo "    <action name=\"Execute\"><execute>xterm -e $EXEC</execute></action>" >>$LXDEMENU
      echo "  </item>" >>$LXDEMENU
    else
      echo "  <item label=\"$APP\">" >>$LXDEMENU
      echo "    <action name=\"Execute\"><execute>$EXEC</execute></action>" >>$LXDEMENU
      echo "  </item>" >>$LXDEMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_lxde_menu &&
build_menu &&
close_lxde_menu ||
echo "Generating of the lxde menu has failed!"

A  => var/lib/enthrall/enthrall.lxp-icewm +74 -0
@@ 1,74 @@
#!/bin/sh

function prepare_menu_location {
# checking which menu to build
  if [ "$OWN_MENU" == "true" ]; then
    LXPMENU="$LXP_USER_MENU"
  else
    LXPMENU="$LXP_MENU"
  fi

# figuring out where to put the menu files
  local menuname=`basename "$LXPMENU"`
  local menudir=`echo "$LXPMENU"|sed "s/\/$menuname//"`

# moving the old menu out of the way
    if [ -f $LXPMENU ]; then
      mv $LXPMENU $LXPMENU.$(date +%Y%m%d%H%M%S)
    fi
    if [ -d $menudir/enthrall ]; then
      mv $menudir/enthrall $menudir/enthrall.$(date +%Y%m%d%H%M%S)
    fi

# preparing the menu dir
  [ -d "$menudir/enthrall" ] || mkdir -p $menudir/enthrall
  cd $menudir
}

function start_lxp_menu {
# the start of the lxp menu
cat >> $LXPMENU << EOF
# Warning, this file is automatically generated by enthrall
# DO NOT EDIT

# entry to get the toolbar buttons into the menu
menufile Tool_bar folder toolbar
EOF
}

function insert_submenu_begin() {
  echo "menufile $1 folder enthrall/$1" >> $LXPMENU
}

function insert_entry() {
    menuline=$1
    local menuname=$(basename $LXPMENU)
    local menudir=$(echo "$LXPMENU"|sed "s/\/$menuname//")
    APP=$(echo $menuline|cut -f1 -d":" )
    EXEC=$(echo $menuline|cut -f4 -d":" )
    TERM=$(echo $menuline|cut -f5 -d":" )
    ICON=$(echo $menuline|cut -f6 -d":" )
    [ -z ${ICON} ] && ICON="default.png"
    if [[ $TERM == true ]] ; then
      echo "prog \"${APP}\" ${ICON} xterm -e ${EXEC}" >> $menudir/enthrall/$LXPSUBMENU
    else
      echo "prog \"${APP}\" ${ICON} ${EXEC}" >> $menudir/enthrall/$LXPSUBMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) LXPSUBMENU="$(echo $line|cut -f2 -d" " )"
                    insert_submenu_begin $LXPSUBMENU ;;
	END_SUB) true;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_lxp_menu &&
build_menu ||
echo "Generating of the lxp menu has failed!"

A  => var/lib/enthrall/enthrall.openbox +96 -0
@@ 1,96 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$OPENBOX_USER_MENU" ] &&
    mv $OPENBOX_USER_MENU $OPENBOX_USER_MENU.$(date +%Y%m%d%H%M%S)
    OPENBOXMENU="$OPENBOX_USER_MENU"
  else
    [ -e "$OPENBOX_MENU" ] &&
    mv $OPENBOX_MENU $OPENBOX_MENU.$(date +%Y%m%d%H%M%S)
    OPENBOXMENU="$OPENBOX_MENU"
  fi

  local menuname=`basename "$OPENBOXMENU"`
  local menudir=`echo "$OPENBOXMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_openbox_menu {
# the start of the openbox menu
cat >> $OPENBOXMENU << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu xmlns="http://openbox.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://openbox.org/
  file:///usr/share/openbox/menu.xsd">
  
<menu id="root-menu" label="Openbox">
EOF
}

function close_openbox_menu {
# closing the openbox menu
cat >> $OPENBOXMENU << EOF
    <separator />
    <menu id="openbox-menu" label="Openbox">
      <item label="ObConf">
        <action name="Execute"><execute>obconf</execute></action>
      </item>
      <item label="Reconfigure">
        <action name="Reconfigure" />
      </item>
      <separator />
      <item label="Exit">
        <action name="Exit" />
      </item>
    </menu>
  </menu>
  
  </openbox_menu>
  
EOF
}

function insert_submenu_begin() {
  echo "<menu id=\"$1\" label=\"$1\">" >> $OPENBOXMENU
}

function insert_submenu_end {
  echo "</menu>" >>$OPENBOXMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "  <item label=\"$APP\">" >>$OPENBOXMENU
      echo "    <action name=\"Execute\"><execute>xterm -e $EXEC</execute></action>" >>$OPENBOXMENU
      echo "  </item>" >>$OPENBOXMENU
    else
      echo "  <item label=\"$APP\">" >>$OPENBOXMENU
      echo "    <action name=\"Execute\"><execute>$EXEC</execute></action>" >>$OPENBOXMENU
      echo "  </item>" >>$OPENBOXMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_openbox_menu &&
build_menu &&
close_openbox_menu ||
echo "Generating of the openbox menu has failed!"

A  => var/lib/enthrall/enthrall.pekwm +127 -0
@@ 1,127 @@
#!/bin/sh

## Please note, pekwm really doesn't like tabs in it's menu.
## if you want the generation to work, use spaces instead.


function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$PEKWM_USER_MENU" ] &&
    mv $PEKWM_USER_MENU $PEKWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    PEKWMMENU="$PEKWM_USER_MENU"
  else
    [ -e "$PEKWM_MENU" ] &&
    mv $PEKWM_MENU $PEKWM_MENU.$(date +%Y%m%d%H%M%S)
    PEKWMMENU="$PEKWM_MENU"
  fi

  local menuname=`basename "$PEKWMMENU"`
  local menudir=`echo "$PEKWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_pekwm_menu {
# the start of the pekwm menu
cat >> $PEKWMMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the pekwm menu
  
  # Variables
  \$TERM = "xterm +sb -bg black -fg grey90"

  RootMenu = "Pekwm" {
EOF
}

function close_pekwm_menu {
# closing the pekwm menu
cat >> $PEKWMMENU << EOF
  Entry = "----------" { Actions = "NoAction" }

  Submenu = "Pekwm" {
    Submenu = "Others" {
      Entry = "Xterm" { Actions = "RestartOther xterm" }
    }
  Submenu = "Themes" {
    Entry { Actions = "Dynamic /usr/share/pekwm/scripts/pekwm_themeset.pl /usr/share/pekwm/themes" }
  }
  Entry = "Reload" { Actions = "Reload" }
  Entry = "Restart" { Actions = "Restart" }
  Entry = "Exit" { Actions = "Exit" }
  }
}
  
  WindowMenu = "Window Menu" {
    Entry = "(Un)Stick" { Actions = "Stick" }
    Entry = "(Un)Shade" { Actions = "Shade" }
    Submenu = "Maximize" {
      Entry = "Full" { Actions = "Maximize " }
      Entry = "Horizontal" { Actions = "MaximizeHorizontal " }
      Entry = "Vertical" { Actions = "MaximizeVertical " }
    }
    Submenu = "Stacking" {
      Entry = "Raise " { Actions = "Raise " }
      Entry = "Lower" { Actions = "Lower" }
      Entry = "Always On Top " { Actions = "AlwaysOnTop " }
      Entry = "Always Below" { Actions = "AlwaysBelow " }
    }
    Submenu = "Decor" {
      Entry = "Decor" { Actions = "ToggleDecor " }
      Entry = "Border" { Actions = "ToggleBorder " }
      Entry = "Titlebar" { Actions = "ToggleTitlebar " }
    }
    SubMenu = "Send To" {
      Entry = "Workspace 1" { Actions = "SendToWorkspace 1" }
      Entry = "Workspace 2" { Actions = "SendToWorkspace 2" }
      Entry = "Workspace 3" { Actions = "SendToWorkspace 3" }
      Entry = "Workspace 4" { Actions = "SendToWorkspace 4" }
    }
      Entry = "Iconify " { Actions = "Iconify " }
      Entry = "Close" { Actions = "Close" }
      Entry = "Kill " { Actions = "Kill " }
  }
  
  # End of the pekwm menu
EOF
}

function insert_submenu_begin() {
  echo "Submenu = \"$1\" {" >> $PEKWMMENU
}

function insert_submenu_end {
  echo "}" >> $PEKWMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "Entry = \"$APP\" { Actions = \"Exec xterm -e $EXEC \" }" >>$PEKWMMENU
    else
      echo "Entry = \"$APP\" { Actions = \"Exec $EXEC \" }" >>$PEKWMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_pekwm_menu &&
build_menu &&
close_pekwm_menu ||
echo "Generating of the pekwm menu has failed!"

A  => var/lib/enthrall/enthrall.pwm +114 -0
@@ 1,114 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$PWM_USER_MENU" ] &&
    mv $PWM_USER_MENU $PWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    PWMMENU="$PWM_USER_MENU"
  else
    [ -e "$PWM_MENU" ] &&
    mv $PWM_MENU $PWM_MENU.$(date +%Y%m%d%H%M%S)
    PWMMENU="$PWM_MENU"
  fi

  local menuname=`basename "$PWMMENU"`
  local menudir=`echo "$PWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_pwmmenu {
# the start of the pwm menu
cat >> $PWMMENU << EOF
  # Warning, this file is automatically generated
  # DO NOT EDIT
  #
  # Start of the pwm menus
  
  menu "exit_menu", "Exit" {
          entry "Restart", "restart"
          entry "Exit", "exit"
  }
  
  menu "root_menu", "Root Menu" {

EOF
}

function close_pwmmenu {
# closing the pwm menu
cat >> $PWMMENU << EOF
   menu "pwm_menu", "pwm" {
   entry "PWM manual", "exec", "xterm -T \\"PWM manual\\" -e man pwm"
   submenu "exit_menu"
   }
   }
   
   menu "frame_cwin_menu", "Frame/ClientWin Ops" {
           contextual
           # client window ops 
           entry "Close", "close"
   #       entry "Tg tagged", "toggle_tagged"
   
           # frame ops
           entry "Tg shade", "toggle_shade"
           entry "Tg stick", "toggle_stick"
           entry "Tg maximize", "toggle_maximize", 3
   
           # Put this far from close to prevent accidental kill
           entry "Kill", "kill"
   
           entry "Detach", "detach"
           submenu "attach_menu"
           
           submenu "movetows_menu"
   }
   
   menu "dockwin_menu", "DockWin Ops" {
           contextual
           entry "Tg Dir", "toggle_dock_dir"
           entry "Close", "close"
           entry "Kill", "kill"
   }
   
   ; End of the pwm menu
EOF
}

function insert_submenu_begin() {
  echo "menu \"$1\", \"$1\" {" >> $PWMMENU
}

function insert_submenu_end {
   echo "}" >> $PWMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo " entry \"$APP\", \"exec\", \"xterm -e $EXEC\"" >> $PWMMENU
    else
      echo " entry \"$APP\", \"exec\", \"$EXEC\"" >> $PWMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_pwmmenu &&
build_menu &&
close_pwmmenu ||
echo "Generating of the pwm menu has failed!"

A  => var/lib/enthrall/enthrall.qvwm +117 -0
@@ 1,117 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$QVWM_USER_MENU" ] &&
    mv $QVWM_USER_MENU $QVWM_USER_MENU.$(date +%Y%m%d%H%M%S)
    QVWMMENU="$QVWM_USER_MENU"
  else
    [ -e "$QVWM_MENU" ] &&
    mv $QVWM_MENU $QVWM_MENU.$(date +%Y%m%d%H%M%S)
    QVWMMENU="$QVWM_MENU"
  fi

  local menuname=`basename "$QVWMMENU"`
  local menudir=`echo "$QVWMMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_qvwmmenu {
# the start of the qvwm menu
cat >> $QVWMMENU << EOF
  ; Warning, this file is automatically generated
  ; DO NOT EDIT
  ;
  ; Start of the qvwm menu
  
  [StartMenu]
EOF
}

function close_qvwmmenu {
# closing the qvwm menu
cat >> $QVWMMENU << EOF
    "QVWM"	"setting32.ani"
    +
      "\&Setting"	"setting32.ani"
      +
    	"\&Taskbar"	"taskbar16.ani"
    	+
    		"\&Bottom"	""		QVWM_BOTTOM
    		"\&Top"		""		QVWM_TOP
    		"\&Left"	""		QVWM_LEFT
    		"\&Right"	""		QVWM_RIGHT
    	-
    -
    "\&Find"	"find32.ani"	""
    "\&Help"	"help32.xpm"	"xman"
    "\&Run"		"run32.ani"	"xterm -geometry 60x1"
    ""			""		QVWM_SEPARATOR
    "\&Exit qvwm        "	"exit32.ani"	QVWM_EXIT
    -
    
  
  ; End of the qvwm menu
EOF
}

function insert_submenu_begin() {
  echo " \"$1\" \"\"" >> $QVWMMENU
  echo " +" >> $QVWMMENU
}

function insert_submenu_end {
  echo " -" >> $QVWMMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    ## stupid qvwm needs the full path to the icons
    ICON_raw=`echo $menuline|cut -f6 -d":" `
    if [ $FIND_ICONS ] && [ ! -z $ICON_raw ] && ! ( echo $ICON_raw |grep "/" > /dev/null ) ; then
        [ -z "$ICON" ] &&
        ICON="$(find /usr/share/pixmaps -name $ICON_raw|head -n1 )"
    else 
      ICON=$ICON_raw
    fi
    if [[ $TERM == true ]] ; then
      echo "  \"$APP\" \"$ICON\" \"xterm -e $EXEC\" " >> $QVWMMENU
    else
      echo "  \"$APP\" \"$ICON\" \"$EXEC\" " >> $QVWMMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
echo ""
echo "Do you want proper icons in your qvwm menu?"
echo "(Warning, this is a slow and disk intensive search!)"
while :; do
  echo "please answer y or n"
  read answer
  case $answer in
    y|Y) FIND_ICONS="true"
         break ;;
    n|N) FIND_ICONS=""
         break ;;
  esac
done
prepare_menu_location &&
start_qvwmmenu &&
build_menu &&
close_qvwmmenu ||
echo "Generating of the qvwm menu has failed!"

A  => var/lib/enthrall/enthrall.waimea +138 -0
@@ 1,138 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$WAIMEA_USER_MENU" ] &&
    mv $WAIMEA_USER_MENU $WAIMEA_USER_MENU.$(date +%Y%m%d%H%M%S)
    WAIMEAMENU="$WAIMEA_USER_MENU"
  else
    [ -e "$WAIMEA_MENU" ] &&
    mv $WAIMEA_MENU $WAIMEA_MENU.$(date +%Y%m%d%H%M%S)
    WAIMEAMENU="$WAIMEA_MENU"
  fi

  local menuname=`basename "$WAIMEAMENU"`
  local menudir=`echo "$WAIMEAMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"

}

function start_waimeamenu {
# the start of the waimea menu
cat >>$WAIMEAMENU << EOF
  ! Warning, this file is automatically generated
  ! DO NOT EDIT
  !
  ! Start of the waimea menu
  
  [start] (rootmenu)
    [title] (Waimea)
EOF
}

function close_waimeamenu {
# closing the waimea menu
cat >>$WAIMEAMENU << EOF
  [submenu] (Waimea)" 
    [sub] (styles) <!stylesdir.pl>
    [submenu] (desktops)
      [item] (go to desktop 1) "gotodesktop(0)"
      [item] (go to desktop 2) "gotodesktop(1)"
      [item] (go to desktop 3) "gotodesktop(2)"
      [item] (go to desktop 4) "gotodesktop(3)"
    [end]
    [restart] (restart)
    [exit]    (exit)
  [end]
  
  !
  ! Window Menu
  !
  [start] (window)
    [title]   (\n)
    [submenu] (settings)
      [checkbox=MAXIMIZED]      @FALSE (maximized)        "maximize"         @TRUE (maximized)        "unmaximize"
      [checkbox=SHADED]         @FALSE (shaded)           "shade"            @TRUE (shaded)           "unshade"
      [checkbox=STICKY]         @FALSE (sticky)           "sticky"           @TRUE (sticky)           "unsticky"
      [checkbox=ALWAYSONTOP]    @FALSE (always on top)    "alwaysontopon"    @TRUE (always on top)    "alwaysontopoff"
      [checkbox=ALWAYSATBOTTOM] @FALSE (always at bottom) "alwaysatbottomon" @TRUE (always at bottom) "alwaysatbottomoff"
      [checkbox=DECORTITLE]     @FALSE (titlebar)         "decortitleon"     @TRUE (titlebar)         "decortitleoff"
      [checkbox=DECORHANDLE]    @FALSE (handlebar)        "decorhandleon"    @TRUE (handlebar)        "decorhandleoff"
      [checkbox=DECORBORDER]    @FALSE (border)           "decorborderon"    @TRUE (border)           "decorborderoff"
      [checkbox=DECORALL]       @FALSE (all decorations)  "decorallon"       @TRUE (all decorations)  "decoralloff"
    [end]
    [sub]     (process info) <!procinfo.pl -host \"\h\" -pid \"\p\">
    [submenu] (desktop functions)
      [sub] (join desktop) <join_desk>
      [start] (join_desk)
        [item] (desktop 1) "joindesktop(0)"
        [item] (desktop 2) "joindesktop(1)"
        [item] (desktop 3) "joindesktop(2)"
        [item] (desktop 4) "joindesktop(3)"
      [end]
      [sub] (part desktop) <part_desk>
      [start] (part_desk)
        [item] (desktop 1) "partdesktop(0)"
        [item] (desktop 2) "partdesktop(1)"
        [item] (desktop 3) "partdesktop(2)"
        [item] (desktop 4) "partdesktop(3)"
      [end]
      [sub] (send to desktop) <send_desk>
      [start] (send_desk)
        [item] (desktop 1) "partcurrentjoindesktop(0)"
        [item] (desktop 2) "partcurrentjoindesktop(1)"
        [item] (desktop 3) "partcurrentjoindesktop(2)"
        [item] (desktop 4) "partcurrentjoindesktop(3)"
      [end]
      [item] (join all)     "joinalldesktops"
      [item] (part all)     "partalldesktopsexceptcurrent"
      [item] (part current) "partcurrentdesktop"
    [end]
    [item]    (raise)        "raise"
    [item]    (lower)        "lower"
    [item]    (kill client)  "kill"
    [item]    (close)        "close"
  [end]
  
  # End of the waimea menu
EOF
}

function insert_submenu_begin() {
  echo "[submenu] ($1)" >> $WAIMEAMENU
}

function insert_submenu_end {
  echo "[end]" >> $WAIMEAMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "[item] ("$APP") {xterm -e $EXEC}" >> $WAIMEAMENU
    else
      echo "[item] ("$APP") {$EXEC}" >> $WAIMEAMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_waimeamenu &&
build_menu &&
close_waimeamenu ||
echo "Generating of the waimea menu has failed!"

A  => var/lib/enthrall/enthrall.windowmaker +156 -0
@@ 1,156 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$WINDOWMAKER_USER_MENU" ] &&
    mv $WINDOWMAKER_USER_MENU $WINDOWMAKER_USER_MENU.$(date +%Y%m%d%H%M%S)
    WMAKERMENU="$WINDOWMAKER_USER_MENU"
  else
    [ -e "$WINDOWMAKER_MENU" ] &&
    mv $WINDOWMAKER_MENU $WINDOWMAKER_MENU.$(date +%Y%m%d%H%M%S)
    WMAKERMENU="$WINDOWMAKER_MENU"
  fi

  local menuname=`basename "$WMAKERMENU"`
  local menudir=`echo "$WMAKERMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_wmakermenu {
# the start of the windowmaker menu
cat >> $WMAKERMENU << EOF
("Applications",
("Info",
("Info Panel", INFO_PANEL),
("Legal", LEGAL_PANEL),
("System Console", EXEC, "xconsole"),
("System Load", SHEXEC, "xosview || xload"),
("Process List", EXEC, "xterm -e top"),
("Manual Browser", EXEC, "xman")
),
("Run...", SHEXEC, "%a(Run,Type command to run:)"),
("XTerm", EXEC, "xterm -sb"),
("Workspaces", WORKSPACE_MENU),
EOF
}

function close_wmakermenu {
# closing the windowmaker menu
cat >> $WMAKERMENU << EOF
("Selection",
("Copy", SHEXEC, "echo '%s' | wxcopy"),
("Mail To", EXEC, "xterm -name mail -T Pine -e pine %s"),
("Navigate", EXEC, "mozilla %s"),
("Search in Manual", EXEC, "MANUAL_SEARCH(%s)")
),
("Commands",
("Hide Others", HIDE_OTHERS),
("Show All", SHOW_ALL),
("Arrange Icons", ARRANGE_ICONS),
("Refresh", REFRESH),
("Lock", EXEC, "xlock -allowroot -usefirst")
),
("Appearance",
("Themes", OPEN_MENU, "-noext /usr/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes WITH setstyle"),
("Styles", OPEN_MENU, "-noext /usr/share/WindowMaker/Styles $HOME/GNUstep/Library/WindowMaker/Styles WITH setstyle"),
("Icon Sets", OPEN_MENU, "-noext /usr/share/WindowMaker/IconSets $HOME/GNUstep/Library/WindowMaker/IconSets WITH seticons"),
("Background",
("Solid",
("Black", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, black)'"),
("Blue",  EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#505075\\\")'"),
("Indigo", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#243e6c\\\")'"),
("Bluemarine", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#224477\\\")'"),
("Purple", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#554466\\\")'"),
("Wheat", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, wheat4)'"),
("Dark Gray", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#333340\\\")'"),
("Wine", EXEC, "wdwrite WindowMaker WorkspaceBack '(solid, \\\"#400020\\\")'")
),
("Gradient",
("Sunset", EXEC, "wdwrite WindowMaker WorkspaceBack '(mvgradient, deepskyblue4, black, deepskyblue4, tomato4)'"),
("Sky", EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, blue4, white)'"),
("Blue Shades",   EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#7080a5\\\", \\\"#101020\\\")'"),
("Indigo Shades", EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#746ebc\\\", \\\"#242e4c\\\")'"),
("Purple Shades", EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#654c66\\\", \\\"#151426\\\")'"),
("Wheat Shades",  EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#a09060\\\", \\\"#302010\\\")'"),
("Grey Shades",   EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#636380\\\", \\\"#131318\\\")'"),
("Wine Shades",   EXEC, "wdwrite WindowMaker WorkspaceBack '(vgradient, \\\"#600040\\\", \\\"#180010\\\")'")
),
("Images", OPEN_MENU, "-noext /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds WITH wmsetbg -u -t")
),   
("Save Theme", SHEXEC, "getstyle -t $HOME/GNUstep/Library/WindowMaker/Themes/\\\"%a(Theme name)\\\""),
("Save IconSet", SHEXEC, "geticonset $HOME/GNUstep/Library/WindowMaker/IconSets/\\\"%a(IconSet name)\\\""),
("Preferences Utility", EXEC, "/usr/local/GNUstep/Applications/WPrefs.app/WPrefs")
), 
("Session",
("Save Session", SAVE_SESSION),
("Clear Session", CLEAR_SESSION),
("Restart Window Maker", RESTART),
("Exit", EXIT)
)
)
EOF
}

function insert_submenu_begin() {
  echo "(\"$1\"," >> $WMAKERMENU
}

function insert_submenu_end {
  echo ")," >> $WMAKERMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "(\"$APP\", EXEC, \"xterm -e $EXEC\")," >> $WMAKERMENU
    else
      echo "(\"$APP\", EXEC, \"$EXEC\")," >> $WMAKERMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end `echo $line|cut -f2 -d" " ` ;;
        *) insert_entry "$line" ;;
    esac
  done
}

function clean_menu {
# wmaker insists removing the "," behind the last entry in a menu
# this is an ugly hack to take care of that

local prevline
local line
local newline

cat $WMAKERMENU | while read line ; do
  if [ -z "$prevline" ] ;then
    prevline="${line}" ;
  elif [ "${line}" == ")," ]; then
    newline="$(echo "${prevline%,}")"
    echo "${newline}" >> $WMAKERMENU.new ;
  else
    echo "${prevline}" >>$WMAKERMENU.new ;
  fi
  prevline="${line}"
  newline=
done
echo ")" >> $WMAKERMENU.new
mv $WMAKERMENU.new $WMAKERMENU
}

# building the menu
prepare_menu_location &&
start_wmakermenu &&
build_menu &&
close_wmakermenu &&
clean_menu ||
echo "Generating of the windowmaker menu has failed!"

A  => var/lib/enthrall/enthrall.xfce4-session +101 -0
@@ 1,101 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$XFCE_USER_MENU" ] &&
    mv $XFCE_USER_MENU $XFCE_USER_MENU.$(date +%Y%m%d%H%M%S)
    XFCEMENU="$XFCE_USER_MENU"
  else
    [ -e "$XFCE_MENU" ] &&
    mv $XFCE_MENU $XFCE_MENU.$(date +%Y%m%d%H%M%S)
    XFCEMENU="$XFCE_MENU"
  fi

  local menuname=`basename "$XFCEMENU"`
  local menudir=`echo "$XFCEMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_xfce_menu {
# the start of the xfce menu
cat >> $XFCEMENU << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xfdesktop-menu>
  
<xfdesktop-menu>

        <title name="Desktop Menu" icon="xfce4-backdrop"/>

        <separator/>

        <app name="Run Program..." cmd="xfrun4" icon="gnome-fs-executable"/>

        <separator/>

        <app name="Terminal" cmd="xfterm4" icon="gnome-terminal"/>
        <app name="File Manager (xffm)" cmd="xffm" icon="file-manager"/>

        <separator/>

EOF
}

function close_xfce_menu {
# closing the xfce menu
cat >> $XFCEMENU << EOF

        <separator/>

        <menu name="XFCE" icon="xfce_xicon1">
            <menu name="Settings" icon="gnome-settings">
                <app name="Settings Manager" cmd="xfce-setting-show" icon="gnome-settings"/>
            </menu>
            <app name="Help" cmd="xfhelp4" icon="gnome-help"/>
            <app name="About Xfce" cmd="xfce4-about" icon="gnome-info"/>
            <separator/>
            <app name="Quit" cmd="xfce4-session-logout" icon="gnome-logout"/>
         </menu>
</xfdesktop-menu>
EOF
}

function insert_submenu_begin() {
        echo "        <menu name=\"$1\">" >> $XFCEMENU
}

function insert_submenu_end {
        echo "        </menu>" >>$XFCEMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    ICON=`echo $menuline|cut -f6 -d":" `
    [ -z ${ICON} ] && ICON="xfce-unknown"
    if [[ $TERM == true ]] ; then
      echo "                <app name=\"$APP\" term=\"true\" cmd=\"$EXEC\" icon=\"$ICON\"/>" >> $XFCEMENU
    else
      echo "                <app name=\"$APP\" cmd=\"$EXEC\" icon=\"$ICON\"/>" >> $XFCEMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_xfce_menu &&
build_menu &&
close_xfce_menu ||
echo "Generating of the xfce menu has failed!"

A  => var/lib/enthrall/wmaker.menu +141 -0
@@ 1,141 @@
#!/bin/sh

function prepare_menu_location {
# moving the old menu out of the way

  if [ "$OWN_MENU" == "true" ]; then
    [ -e "$WINDOWMAKER_USER_MENU" ] &&
    mv $WINDOWMAKER_USER_MENU $WINDOWMAKER_USER_MENU.$(date +%Y%m%d%H%M%S)
    WMAKERMENU="$WINDOWMAKER_USER_MENU"
  else
    [ -e "$WINDOWMAKER_MENU" ] &&
    mv $WINDOWMAKER_MENU $WINDOWMAKER_MENU.$(date +%Y%m%d%H%M%S)
    WMAKERMENU="$WINDOWMAKER_MENU"
  fi

  local menuname=`basename "$WMAKERMENU"`
  local menudir=`echo "$WMAKERMENU"|sed "s/\/$menuname//"`
  [ -d "$menudir" ] || mkdir -p "$menudir"
}

function start_wmakermenu {
# the start of the windowmaker menu
cat >> $WMAKERMENU << EOF
# Warning, this file is automatically generated
# DO NOT EDIT
#
# Start of the windowmaker menu

#include "wmmacros"

"Applications" MENU
	"Info" MENU
		"Info Panel" INFO_PANEL
		"Legal" LEGAL_PANEL
		"System Console" EXEC xconsole
		"Manual Browser" EXEC xman
	"Info" END
	"Run..." SHEXEC %a(Run,Type command to run:)
EOF
}

function close_wmakermenu {
# closing the windowmaker menu
cat >> $WMAKERMENU << EOF

# End of the windowmaker menu
	"Selection" MENU
		"Copy" SHEXEC echo '%s' | wxcopy
		"Mail To" EXEC xterm -name mail -T "Pine" -e pine %s
		"Navigate" EXEC netscape %s
		"Search in Manual" SHEXEC MANUAL_SEARCH(%s)
	"Selection" END

	"Commands" MENU
		"Hide Others" HIDE_OTHERS
		"Show All" SHOW_ALL
		"Arrange Icons" ARRANGE_ICONS
		"Refresh" REFRESH
		"Lock" EXEC xlock -allowroot -usefirst
	"Commands" END

	"Appearance" MENU
		"Themes" OPEN_MENU -noext THEMES_DIR $HOME/GNUstep/Library/WindowMaker/Themes WITH setstyle
		"Styles" OPEN_MENU -noext STYLES_DIR $HOME/GNUstep/Library/WindowMaker/Styles WITH setstyle
		"Icon Sets" OPEN_MENU -noext ICON_SETS_DIR $HOME/GNUstep/Library/WindowMaker/IconSets WITH seticons
		"Background" MENU
			"Solid" MENU
				"Black" WS_BACK '(solid, black)'
				"Blue"  WS_BACK '(solid, "#505075")'
				"Indigo" WS_BACK '(solid, "#243e6c")'
				"Bluemarine" WS_BACK '(solid, "#224477")'
				"Purple" WS_BACK '(solid, "#554466")'
				"Wheat"  WS_BACK '(solid, "wheat4")'
				"Dark Gray"  WS_BACK '(solid, "#333340")'
				"Wine" WS_BACK '(solid, "#400020")'
				"Solid" END
			"Gradient" MENU
				"Sunset" WS_BACK '(mvgradient, deepskyblue4, black, deepskyblue4, tomato4)'
				"Sky" WS_BACK '(vgradient, blue4, white)'
    			"Blue Shades" WS_BACK '(vgradient, "#7080a5", "#101020")'
				"Indigo Shades" WS_BACK '(vgradient, "#746ebc", "#242e4c")'
			    "Purple Shades" WS_BACK '(vgradient, "#654c66", "#151426")'
    			"Wheat Shades" WS_BACK '(vgradient, "#a09060", "#302010")'
    			"Grey Shades" WS_BACK '(vgradient, "#636380", "#131318")'
    			"Wine Shades" WS_BACK '(vgradient, "#600040", "#180010")'
			"Gradient" END
			"Images" OPEN_MENU -noext BACKGROUNDS_DIR $HOME/GNUstep/Library/WindowMaker/Backgrounds WITH wmsetbg -u -t
		"Background" END
		"Save Theme" SHEXEC getstyle -t $HOME/GNUstep/Library/WindowMaker/Themes/"%a(Theme name,Enter file name:)"
		"Save IconSet" SHEXEC geticonset $HOME/GNUstep/Library/WindowMaker/IconSets/"%a(IconSet name,Enter file name:)"
		"Preferences Utility" EXEC /usr/local/GNUstep/Applications/WPrefs.app/WPrefs
	"Appearance" END

	"Session" MENU
		"Save Session" SAVE_SESSION
		"Clear Session" CLEAR_SESSION
		"Restart Window Maker" RESTART
		"Start WindowMaker" RESTART windowmaker
		"Start IceWM" RESTART icewm
		"Exit"  EXIT
	"Session" END
"Applications" END
EOF
}

function insert_submenu_begin() {
  echo "\"$1\" MENU" >> $WMAKERMENU
}

function insert_submenu_end {
  echo "\"$1\" END" >> $WMAKERMENU
}

function insert_entry() {
    menuline=$1
    APP=`echo $menuline|cut -f1 -d":" `
    EXEC=`echo $menuline|cut -f4 -d":" `
    TERM=`echo $menuline|cut -f5 -d":" `
    if [[ $TERM == true ]] ; then
      echo "\"$APP\" EXEC xterm -e $EXEC" >> $WMAKERMENU
    else
      echo "\"$APP\" EXEC $EXEC" >> $WMAKERMENU
    fi
}

function build_menu {
  cat $SORTED_INVENTORY | while read line ; do
    case $line in
        START_SUB*) insert_submenu_begin `echo $line|cut -f2 -d" " ` ;;
	END_SUB) insert_submenu_end `echo $line|cut -f2 -d" " ` ;;
        *) insert_entry "$line" ;;
    esac
  done
}

# building the menu
prepare_menu_location &&
start_wmakermenu &&
build_menu &&
close_wmakermenu ||
echo "Generating of the windowmaker menu has failed!"