home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / bin / gnome-wm < prev    next >
Encoding:
Text File  |  2006-08-30  |  2.2 KB  |  104 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. # This script has been heavily modified to support Debian's
  10. # alternatives system.
  11.  
  12. # sm-client-id value
  13. SMID=
  14. # default-wm value
  15. DEFWM=
  16.  
  17. #read in the arguments
  18. GET=
  19. for n in "$@" ; do
  20.   case "$GET" in
  21.     smid)
  22.       SMID=$n
  23.       GET=
  24.       ;;
  25.     defwm)
  26.       DEFWM=$n
  27.       GET=
  28.       ;;
  29.     *)
  30.       case "$n" in
  31.         --sm-client-id)
  32.           GET=smid
  33.           ;;
  34.         --default-wm)
  35.           GET=defwm
  36.           ;;
  37.       esac
  38.       ;;
  39.   esac
  40. done
  41.  
  42. if ! which "$WINDOW_MANAGER" > /dev/null; then
  43.   # Get --default-wm
  44.   if which "$DEFWM" > /dev/null; then
  45.     WINDOW_MANAGER=$DEFWM
  46.     if [ "$WINDOW_MANAGER" = x-window-manager ]; then
  47.       WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
  48.     fi
  49.   # if nothing is found, first use metacity
  50.   elif [ -x /usr/bin/metacity ]; then
  51.     WINDOW_MANAGER=/usr/bin/metacity
  52.   elif [ -x /usr/bin/sawfish ]; then
  53.     WINDOW_MANAGER=/usr/bin/sawfish
  54.   else
  55.     WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
  56.   fi
  57. fi
  58.  
  59. # If no window manager can be found, we default to xterm
  60.  
  61. if [ -z "$WINDOW_MANAGER" ] ; then
  62.   echo "WARNING: No window manager can be found."
  63.   WINDOW_MANAGER=`readlink /etc/alternatives/x-terminal-emulator 2>/dev/null`
  64. fi
  65.  
  66. # If there is no xterm, they're really screwed.
  67. if [ ! "$WINDOW_MANAGER" ]; then
  68.   echo "ERROR: No window manager and no xterm!"
  69.   exit 1
  70. fi
  71.  
  72. # Now create options OPT1 and OPT2 based on the windowmanager used
  73. OPT1=
  74. OPT2=
  75. if [ ! -z "$SMID" ] ; then
  76.   case `basename $WINDOW_MANAGER` in
  77.     sawfish|sawmill|metacity)
  78.       OPT1=--sm-client-id=$SMID
  79.       ;;
  80.     openbox|xfwm4)
  81.       OPT1=--sm-client-id
  82.       OPT2=$SMID
  83.       ;;
  84.     enlightenment|twm)
  85.       OPT1=-clientId
  86.       OPT2=$SMID
  87.       ;;
  88.     fvwm|fvwm2)
  89.       OPT1=--clientid
  90.       OPT2=$SMID
  91.       ;;
  92.     lwm)
  93.       OPT1=-s
  94.       OPT2=$SMID
  95.       ;;
  96.     #FIXME: add all other windowmanagers here with their proper options
  97.   esac
  98. fi
  99.  
  100. exec "$WINDOW_MANAGER" $OPT1 $OPT2
  101.  
  102. echo "ERROR: No window manager could run!"
  103. exit 1
  104.