home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / gnome-wm < prev    next >
Encoding:
Text File  |  2010-11-06  |  2.7 KB  |  135 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. # Migrate compiz to compiz-manager if possible and needed
  44. if [ "x$WINDOW_MANAGER" = "xcompiz" -o "x$DEFWM" = "xcompiz" ]; then
  45.   which compiz-manager > /dev/null 2>&1
  46.   if [ $? -eq 0 ]; then
  47.     if [ "x$WINDOW_MANAGER" = "xcompiz" ]; then
  48.       WINDOW_MANAGER="compiz-manager"
  49.     fi
  50.     if [ "x$DEFWM" = "xcompiz" ]; then
  51.       DEFWM="compiz-manager"
  52.     fi
  53.   fi
  54. fi
  55.  
  56. # Avoid looping if the session configuration tells us to use gnome-wm or if
  57. # the user forces gnome-wm via WINDOW_MANAGER
  58. if [ "x$WINDOW_MANAGER" = "xgnome-wm" ]; then
  59.   WINDOW_MANAGER=""
  60. fi
  61.  
  62. if [ -z "$WINDOW_MANAGER" ] ; then
  63.   # Create a list of window manager we can handle, trying to only use the
  64.   # compositing ones when it makes sense
  65.  
  66.   KNOWN_WM="metacity mutter sawfish"
  67.  
  68.   for wm in $KNOWN_WM; do
  69.     if [ -x /usr/bin/"$wm" ]; then
  70.       WINDOW_MANAGER=/usr/bin/"$wm"
  71.       break
  72.     fi
  73.   done
  74.  
  75. fi
  76.  
  77. # Look for the default window manager on the system
  78.  
  79. if [ -z "$WINDOW_MANAGER" ] ; then
  80.   WINDOW_MANAGER=$(readlink /etc/alternatives/x-window-manager 2>/dev/null)
  81. fi
  82.  
  83. # Now create options OPT1, OPT2 and OPT3 based on the windowmanager used
  84. OPT1=
  85. OPT2=
  86. OPT3=
  87. OPT4=
  88. if [ ! -z "$SMID" ] ; then
  89.   case `basename $WINDOW_MANAGER` in
  90.     sawfish|sawmill|metacity|mutter)
  91.       OPT1=--sm-client-id=$SMID
  92.       ;;
  93.     openbox|enlightenment|e16)
  94.       OPT1=--sm-client-id
  95.       OPT2=$SMID
  96.       ;;
  97.     twm)
  98.       OPT1=-clientId
  99.       OPT2=$SMID
  100.       ;;
  101.     lwm)
  102.       OPT1=-s
  103.       OPT2=$SMID
  104.       ;;
  105.     fvwm|fvwm2)
  106.       OPT1=-i
  107.       OPT2=$SMID
  108.       ;;
  109.     compiz|compiz-manager)
  110.       OPT1=--sm-client-id
  111.       OPT2=$SMID
  112.       ;;
  113.     beryl)
  114.       OPT1=--sm-client-id
  115.       OPT2=$SMID
  116.       ;;
  117.     #FIXME: add all other windowmanagers here with their proper options
  118.   esac
  119. fi
  120.  
  121. case `basename $WINDOW_MANAGER` in
  122.   compiz)
  123.     gtk-window-decorator &
  124.     #OPT3=glib
  125.     OPT4=gconf
  126.     ;;
  127.   beryl)
  128.     emerald &
  129.     ;;
  130. esac
  131.  
  132. exec "$WINDOW_MANAGER" $OPT1 $OPT2 $OPT3 $OPT4
  133.  
  134. echo "ERROR: No window manager could run!"
  135.