#!/bin/sh
#
# Time-stamp: <2009/09/10 19:54:47 CEST luca@gismo.pca.it>
#
# Copyright 2007 Luca Capello <luca@pca.it>
#           2011 Desmond O. Chang <dochang@gmail.com>
# This file is part of the Debian StumpWM package and is licensed
# under the terms of the GNU GPL version 2 or later.  Check
# /usr/share/doc/stumpwm/copyright for more information.
#
# StumpWM startup file.  Check /usr/share/doc/stumpwm/README.Debian
# to know how to setup your ~/.stumpwmrc file to define the Common
# Lisp implementation StumpWM should use.


LOADER="/usr/lib/stumpwm/load.lisp"

load_lisp() {
    case "$1" in
	cmucl)
	    cmucl -load "$LOADER"
	    ;;
	sbcl)
	    sbcl --load "$LOADER"
	    ;;
	clisp)
	    clisp "$LOADER"
	    ;;
	*)
	    echo "Unkown Common Lisp implementation."
	    exit 1
	    ;;
    esac
}

if [ -z "$LISP" ]; then
    LISP_STUMPWMRC_TMP="`grep debian= $HOME/.stumpwmrc`"
    LISP_STUMPWMRC=${LISP_STUMPWMRC_TMP##*=}
    LISP=${LISP_STUMPWMRC:-clisp}
fi

if ! which $LISP >/dev/null; then
    echo "CL implementation $LISP not found in your \$PATH."
    exit 1
fi

load_lisp $LISP

exit 0
