home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / usr / bin / gnome-wm < prev    next >
Text File  |  2010-05-19  |  4KB  |  180 lines

  1. #!/bin/sh
  2.  
  3. # The user can specify his prefered WM by setting the WINDOW_MANAGER
  4. # environment variable.
  5. #
  6. # If this is not set, we search a list of known windowmanagers and use
  7. # the first one that is found in the users's PATH
  8. #
  9. # NOTE: DON'T USE THIS.  Please have your window manager install
  10. # a desktop file and change the gconf key
  11. # /desktop/gnome/session/required_components/windowmanager
  12.  
  13. # sm-client-id value
  14. SMID=
  15. # default-wm value
  16. DEFWM=
  17.  
  18. #read in the arguments
  19. GET=
  20. for n in "$@" ; do
  21.   case "$GET" in
  22.     smid)
  23.       SMID=$n
  24.       GET=
  25.       ;;
  26.     defwm)
  27.       DEFWM=$n
  28.       GET=
  29.       ;;
  30.     *)
  31.       case "$n" in
  32.         --sm-client-id)
  33.           GET=smid
  34.           ;;
  35.         --default-wm)
  36.           GET=defwm
  37.           ;;
  38.       esac
  39.       ;;
  40.   esac
  41. done
  42.  
  43. # WINDOW_MANAGER overrides all
  44. if [ -z "$WINDOW_MANAGER" ] ; then
  45.     WINDOW_MANAGER=`gconftool-2 --get /desktop/gnome/session/required_components/windowmanager 2> /dev/null`
  46. fi
  47.  
  48. # Migrate compiz to compiz-manager if possible and needed
  49. if [ "x$WINDOW_MANAGER" = "xcompiz" -o "x$DEFWM" = "xcompiz" ]; then
  50.   which compiz-manager > /dev/null 2>&1
  51.   if [ $? -eq 0 ]; then
  52.     if [ "x$WINDOW_MANAGER" = "xcompiz" ]; then
  53.       WINDOW_MANAGER="compiz-manager"
  54.     fi
  55.     if [ "x$DEFWM" = "xcompiz" ]; then
  56.       DEFWM="compiz-manager"
  57.     fi
  58.   fi
  59. fi
  60.  
  61. # Avoid looping if the session configuration tells us to use gnome-wm or if
  62. # the user forces gnome-wm via WINDOW_MANAGER
  63. if [ "x$WINDOW_MANAGER" = "xgnome-wm" ]; then
  64.   WINDOW_MANAGER=""
  65. fi
  66.  
  67. if [ -z "$WINDOW_MANAGER" ] ; then
  68.   # Create a list of window manager we can handle, trying to only use the
  69.   # compositing ones when it makes sense
  70.  
  71.   if [ "x$XDG_CONFIG_HOME" = "x" ]; then
  72.     COMPIZ_ENABLED_FILE="$HOME/.config/compiz/enable-compiz"
  73.   else
  74.     COMPIZ_ENABLED_FILE="$XDG_CONFIG_HOME/compiz/enable-compiz"
  75.   fi
  76.  
  77.   #xdpyinfo 2> /dev/null | grep -q "^ *Composite$" 2> /dev/null
  78.   #IS_X_COMPOSITED=$?
  79.   IS_X_COMPOSITED=0
  80.  
  81.   KNOWN_WM="sawfish sawmill enlightenment icewm wmaker fvwm2 qvwm fvwm twm kwm"
  82.   if [ $IS_X_COMPOSITED -eq 0 ] ; then
  83.     KNOWN_WM="mutter compiz-manager compiz beryl $KNOWN_WM"
  84.   fi
  85.   # metacity is still the default wm in GNOME
  86.   KNOWN_WM="metacity $KNOWN_WM"
  87.  
  88.   if test -f "$COMPIZ_ENABLED_FILE" -a "$COMPIZ_ENABLED_FILE" -nt /etc/X11/xorg.conf; then
  89.     KNOWN_WM="compiz-manager $KNOWN_WM"
  90.   else
  91.       if [ ! -f "$HOME/.config/compiz/disable-compiz" ] ; then
  92.          # Check to see if hardware is supported by compiz, to have it as default WM if so
  93.          CM_DRY=yes compiz-manager > /dev/null 2>&1
  94.          if test $? -eq 0; then
  95.          KNOWN_WM="compiz-manager $KNOWN_WM"
  96.          fi
  97.       fi
  98.   fi
  99.  
  100.   OLDIFS=$IFS
  101.   if [ -z "$DEFWM" -o "x$DEFWM" = "xgnome-wm" ]; then
  102.  
  103.     for wm in $KNOWN_WM ; do
  104.       IFS=":"
  105.       for dir in $PATH ; do
  106.         if [ -x "$dir/$wm" ] ; then
  107.           WINDOW_MANAGER="$dir/$wm"
  108.           break 2
  109.         fi
  110.       done
  111.       IFS=$OLDIFS
  112.     done
  113.  
  114.   else
  115.     WINDOW_MANAGER=$DEFWM
  116.   fi
  117.   IFS=$OLDIFS
  118. fi
  119.  
  120. # If no window manager can be found, we default to xterm
  121.  
  122. if [ -z "$WINDOW_MANAGER" ] ; then
  123.   echo "WARNING: No window manager can be found."
  124.   WINDOW_MANAGER=xterm
  125. fi
  126.  
  127. # Now create options OPT1, OPT2 and OPT3 based on the windowmanager used
  128. OPT1=
  129. OPT2=
  130. OPT3=
  131. OPT4=
  132. if [ ! -z "$SMID" ] ; then
  133.   case `basename $WINDOW_MANAGER` in
  134.     sawfish|sawmill|metacity|mutter)
  135.       OPT1=--sm-client-id=$SMID
  136.       ;;
  137.     openbox|enlightenment|e16)
  138.       OPT1=--sm-client-id
  139.       OPT2=$SMID
  140.       ;;
  141.     twm)
  142.       OPT1=-clientId
  143.       OPT2=$SMID
  144.       ;;
  145.     lwm)
  146.       OPT1=-s
  147.       OPT2=$SMID
  148.       ;;
  149.     fvwm)
  150.       OPT1=-i
  151.       OPT2=$SMID
  152.       ;;
  153.     compiz|compiz-manager)
  154.       OPT1=--sm-client-id
  155.       OPT2=$SMID
  156.       ;;
  157.     beryl)
  158.       OPT1=--sm-client-id
  159.       OPT2=$SMID
  160.       ;;
  161.     #FIXME: add all other windowmanagers here with their proper options
  162.   esac
  163. fi
  164.  
  165. case `basename $WINDOW_MANAGER` in
  166.   compiz)
  167.     export LIBGL_ALWAYS_INDIRECT=1
  168.     gtk-window-decorator &
  169.     OPT3=glib
  170.     OPT4=gconf
  171.     ;;
  172.   beryl)
  173.     emerald &
  174.     ;;
  175. esac
  176.  
  177. exec $WINDOW_MANAGER $OPT1 $OPT2 $OPT3 $OPT4
  178.  
  179. echo "ERROR: No window manager could run!"
  180.