#!/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## sm-client-id valueSMID=# default-wm valueDEFWM=#read in the argumentsGET=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 ;; esacdone# WINDOW_MANAGER overrides allif [ -z "$WINDOW_MANAGER" ] ; then # Create a list of window manager we can handle, trying to only use the # compositing ones when it makes sense xdpyinfo 2> /dev/null | grep -q "^ *Composite$" 2> /dev/null IS_X_COMPOSITED=$? KNOWN_WM="sawfish sawmill enlightenment icewm wmaker fvwm2 qvwm fvwm twm kwm" if [ $IS_X_COMPOSITED -eq 0 ] ; then KNOWN_WM="compiz beryl $KNOWN_WM" fi # metacity is still the default wm in GNOME KNOWN_WM="metacity $KNOWN_WM" OLDIFS=$IFS if [ -z "$DEFWM" -o "x$DEFWM" = "xgnome-wm" ]; then if /usr/bin/xdpyinfo | /usr/bin/grep -q '^vendor release number: *70000001'; then if [ -x /usr/bin/compiz ]; then if [ -z "$SMID" ]; then exec /usr/bin/compiz --replace --sm-disable glib gconf else exec /usr/bin/compiz --replace --sm-client-id $SMID glib gconf fi fi fi for wm in $KNOWN_WM ; do IFS=":" for dir in $PATH ; do if [ -x "$dir/$wm" ] ; then WINDOW_MANAGER="$dir/$wm" break 2 fi done IFS=$OLDIFS done else WINDOW_MANAGER=$DEFWM fi IFS=$OLDIFSfi# If no window manager can be found, we default to xtermif [ -z "$WINDOW_MANAGER" ] ; then echo "WARNING: No window manager can be found." WINDOW_MANAGER=xtermfi# Now create options OPT1, OPT2 and OPT3 based on the windowmanager usedOPT1=OPT2=OPT3=OPT4=if [ ! -z "$SMID" ] ; then case `basename $WINDOW_MANAGER` in sawfish|sawmill|metacity) OPT1=--sm-client-id=$SMID ;; openbox|enlightenment|e16) OPT1=--sm-client-id OPT2=$SMID ;; twm) OPT1=-clientId OPT2=$SMID ;; lwm) OPT1=-s OPT2=$SMID ;; fvwm) OPT1=-i OPT2=$SMID ;; compiz) OPT1=--sm-client-id OPT2=$SMID ;; beryl) OPT1=--sm-client-id OPT2=$SMID ;; #FIXME: add all other windowmanagers here with their proper options esacficase `basename $WINDOW_MANAGER` in compiz) export LIBGL_ALWAYS_INDIRECT=1 gtk-window-decorator & OPT3=glib OPT4=gconf ;; beryl) emerald & ;;esacexec $WINDOW_MANAGER $OPT1 $OPT2 $OPT3 $OPT4echo "ERROR: No window manager could run!"