[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ next ]


Debian Menu System
Chapter 5 - What packages with menu managers should do


Each package containing a menu manager (i.e., a program that can display a menu) should provide a script or program in /etc/menu-methods/ that can read the menu files. This script will be executed by update-menus, which will feed the menu entries to be installed to your script via standard input (stdin).

The scripts in /etc/menu-methods/ should be configuration files, so the user can tune the behaviour of the script, and they must always include the /etc/menu-methods/menu.h configuration file at the beginning with the command !include menu.h For the same reason, scripts in /etc/menu-methods/ are requested to use the following configurable functions: title() for the title (in place of $title), icon() for the icon (in place of $icon), term() for running text command under X11. sections_translations() for the list of translations of sections name available. This later one is only defined if you !include lang.h

Good examples for these scripts for nearly all Debian window managers are included in the menu package in /usr/share/doc/menu/examples. Note that while working on your script, you can use the tricks described in "The internals of the menu package", section "The update-menus program", to run just your script, instead of having update-menus run all scripts (can save quite a lot of time).

This script should not be executable in the package. Instead the postinst should add the execute bit and then run update-menus (if it is executable).

Similarly, the postrm script when called with option ``remove'' should remove the execute bit and run update-menus (if it is executable).

Here is an example of such a postrm script using sh:

       #!/bin/sh
       set -e
       inst=/etc/menu-methods/#PACKAGE#
       case "$1" in
          remove)
             if [ -f $inst ]; then
                     chmod a-x $inst
                     if [ -x /usr/bin/update-menus ]; then update-menus ; fi
             fi
          ;;
          purge)
              #remove the files that install-menu creates:
              rm -rf /var/lib/foo-wm/menu
          ;;
          upgrade);;
          *)
              echo "postrm called with unknown argument \`$1'" >&2
              exit 0
          ;;
       esac

And here is a good example for a postinst script:

       #!/bin/sh
       set -e
       inst=/etc/menu-methods/#PACKAGE#
       if [ -f $inst ]; then
           chmod a+x $inst
           if [ -x /usr/bin/update-menus ]; then
               update-menus
           fi
       fi

If you are using debhelper, the program dh_installmenu can help you do it.

Please, do not make your package depend on the menu package! The preferred way of telling dpkg that your wm can cooperate with menu is:

        Suggests: menu

Please only consider using "depends" if you feel providing reasonable defaults for systems without menu will make life very difficult for you.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ next ]


Debian Menu System

version 1.4, 31 May 2015

Joost Witteveen mailto:joostje@debian.org
Joey Hess mailto:joeyh@debian.org
Christian Schwarz mailto:schwarz@debian.org
Bill Allombert mailto:ballombe@debian.org