home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # The user can specify his prefered WM by setting the WINDOW_MANAGER
- # environment variable.
- #
- # If this is not set, we search a list of known windowmanagers and use
- # the first one that is found in the users's PATH
- #
- # This script has been heavily modified to support Debian's
- # alternatives system.
-
- # sm-client-id value
- SMID=
- # default-wm value
- DEFWM=
-
- #read in the arguments
- GET=
- for n in "$@" ; do
- case "$GET" in
- smid)
- SMID=$n
- GET=
- ;;
- defwm)
- DEFWM=$n
- GET=
- ;;
- *)
- case "$n" in
- --sm-client-id)
- GET=smid
- ;;
- --default-wm)
- GET=defwm
- ;;
- esac
- ;;
- esac
- done
-
- if ! which "$WINDOW_MANAGER" > /dev/null; then
- # Get --default-wm
- if which "$DEFWM" > /dev/null; then
- WINDOW_MANAGER=$DEFWM
- if [ "$WINDOW_MANAGER" = x-window-manager ]; then
- WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
- fi
- # if nothing is found, first use metacity
- elif [ -x /usr/bin/metacity ]; then
- WINDOW_MANAGER=/usr/bin/metacity
- elif [ -x /usr/bin/sawfish ]; then
- WINDOW_MANAGER=/usr/bin/sawfish
- else
- WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
- fi
- fi
-
- # If no window manager can be found, we default to xterm
-
- if [ -z "$WINDOW_MANAGER" ] ; then
- echo "WARNING: No window manager can be found."
- WINDOW_MANAGER=`readlink /etc/alternatives/x-terminal-emulator 2>/dev/null`
- fi
-
- # If there is no xterm, they're really screwed.
- if [ ! "$WINDOW_MANAGER" ]; then
- echo "ERROR: No window manager and no xterm!"
- exit 1
- fi
-
- # Now create options OPT1 and OPT2 based on the windowmanager used
- OPT1=
- OPT2=
- if [ ! -z "$SMID" ] ; then
- case `basename $WINDOW_MANAGER` in
- sawfish|sawmill|metacity)
- OPT1=--sm-client-id=$SMID
- ;;
- openbox|xfwm4)
- OPT1=--sm-client-id
- OPT2=$SMID
- ;;
- enlightenment|twm)
- OPT1=-clientId
- OPT2=$SMID
- ;;
- fvwm|fvwm2)
- OPT1=--clientid
- OPT2=$SMID
- ;;
- lwm)
- OPT1=-s
- OPT2=$SMID
- ;;
- #FIXME: add all other windowmanagers here with their proper options
- esac
- fi
-
- exec "$WINDOW_MANAGER" $OPT1 $OPT2
-
- echo "ERROR: No window manager could run!"
- exit 1
-