#!/bin/sh
#
#  Blackbox postinst
#
#  Shamelessly ripped off of Marcelo Magallon's script
#     by Brent Fulgham <bfulgham@debian.org>
#
set -e

WMentry="/usr/bin/blackbox"

add_wm_entry ()
{
	update-alternatives --install /usr/bin/x-window-manager x-window-manager $WMentry 50 \
	--slave /usr/share/man/man1/x-window-manager.1.gz x-window-manager.1.gz /usr/share/man/man1/blackbox.1.gz
}

case "$1" in
    configure)
        if [ "$2" ] && dpkg --compare-versions $2 le 0.51.3-12; then
	    update-alternatives --remove x-window-manager /etc/X11/window-managers
	fi

        add_wm_entry

	# clean up after eaarlier debs
	if [ -f /usr/share/blackbox/styles/stylesmenu ]; then
		rm /usr/share/blackbox/styles/stylesmenu
	fi
        
	if [ -f /etc/X11/blackbox/Blackbox-menu ]; then
		rm /etc/X11/blackbox/Blackbox-menu
	fi

        if [ -x /usr/sbin/wm-menu-config ]; then 
            wm-menu-config blackbox on; 
        fi
    ;;

    abort-upgrade|abort-deconfigure|abort-remove)
        # how did we get here?  Force a non-zero exit code
        exit 1
    ;;

    *)
    ;;
esac

#DEBHELPER#
