home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / fj / maillis / xwindow / 18977 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  4.1 KB

  1. Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!onoe
  2. From: cek@sdc.boeing.com (Conrad Kimball)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Re: playing with window managers
  5. Message-ID: <1992Dec30.084734.1256@sm.sony.co.jp>
  6. Date: 30 Dec 92 08:47:34 GMT
  7. Sender: onoe@sm.sony.co.jp (Atsushi Onoe)
  8. Distribution: fj
  9. Organization: Boeing Computer Services, Seattle, WA
  10. Lines: 135
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: 29 Dec 92 07:54:01 GMT
  14. Message-Id: <7690@fury.BOEING.COM>
  15. Newsgroups: comp.windows.x
  16. References: <1992Dec28.025916.22596@spectrum.xerox.com>
  17. Sender: xpert-request@expo.lcs.mit.edu
  18.  
  19. In article <1992Dec28.025916.22596@spectrum.xerox.com> leisner@eso.mc.xerox.com writes:
  20. >
  21. >I normally exec a window manager at the end of my .xinitrc...
  22. >
  23. >But how do I easily select different window managers to try out 
  24. >(I'm talking about twm, vtwm, tvtwm, and ctwm?)
  25. >
  26. >Another apporach is to have a xterm window and the end of the .xinitrc, and
  27. >exiting this window will kill X -- but this I find kludgy..
  28. >
  29. >Should I just kill the X server on my server and everything will die?
  30.  
  31. I use the following "choosewm" script, which I execute as the last command
  32. in my .xinitrc file.  It lets me switch among any of the window managers
  33. available on our system, or to terminate my X session.
  34.  
  35. ------------------------------------------------------------------------
  36. #!/bin/sh
  37.  
  38. # Post a menu to pick a window manager, then execute that window manager.
  39. #
  40. # When the window manager terminates this script regains control.  If the
  41. # window manager terminated with an error condition an error message window
  42. # is popped up; if the window manager terminated normally (i.e. the user
  43. # explicitly terminated it), the window manager menu is popped up and the
  44. # process continues ad infinitum.
  45. #
  46. # The window manager menu includes an entry to quit this process.  If
  47. # this script is run as the last command in your .xinitrc or .xsession
  48. # file, this menu selection serves to terminate the entire X session.
  49. #
  50. # The optional single argument specifies the initial window manager.
  51. #
  52. # This script depends on the contributed tools:
  53. #    xmenu
  54. #    xmessage
  55. #    xprompt
  56.  
  57. PROGRAM=`basename $0`
  58.  
  59. Answer=Retry
  60. while test "${Answer}" = "Retry"; do
  61.  
  62.     if test -n "$1"; then
  63.     Wm=$1
  64.     shift 1
  65.     else
  66.     Wm=`xmenu                            \
  67.         -title "${PROGRAM}"                        \
  68.         -name "${PROGRAM}-xmenu"                    \
  69.         -heading "Choose a window manager"                \
  70.         "TWM"=twm                            \
  71.         "CTWM"=ctwm                            \
  72.         "TVTWM"=tvtwm                        \
  73.         "VTWM"=vtwm                            \
  74.         "MWM"=mwm                            \
  75.         "GWM"=gwm                            \
  76.         -line                            \
  77.         "Quit X"=quit                        \
  78.         `
  79.     fi
  80.  
  81.     case "${Wm}" in
  82.     twm)    WmCmd=twm;;
  83.     ctwm)    WmCmd=ctwm;;
  84.     tvtwm)    WmCmd=tvtwm;;
  85.     vtwm)    WmCmd=vtwm;;
  86.     mwm)    WmCmd=mwm;;
  87.     gwm)    WmCmd=gwm;;
  88.     quit)    exit;;
  89.     *)    WmCmd="${Wm}";;
  90.     esac
  91.     
  92.     # execute ${WmCmd} so we capture its exit code in a shell variable,
  93.     # and a copy of its stderr on a file, while all stdout and stderr
  94.     # information goes wherever it is currently directed, unscathed.
  95.  
  96.     StdErr="${TMPDIR:-/tmp}/choosewm.stderr.$$"
  97.     trap 'rm -fr ${StdErr}' 0 1 2 3 15 18
  98.     rm -f ${StdErr}
  99.     exec 3>&1
  100.     ErrorCode=`exec 4>&1; (eval ${WmCmd} 2>&1 1>&3 3>&-; echo $? >&4) | tee ${StdErr} 1>&2`
  101.     exec 3>&-
  102.     ErrorMessage=`cat ${StdErr}`
  103.     rm -f ${StdErr}
  104.     Answer=Retry
  105.     
  106.     if test ${ErrorCode} -ne 0; then
  107.     
  108.     Answer=`xmessage                        \
  109.         -title "${PROGRAM} error:"                    \
  110.         -name "${PROGRAM}-xmessage"                    \
  111.         -buttons Quit,Retry -print -message                \
  112. "${Wm} failed - error code: ${ErrorCode}
  113.  
  114. Command was:
  115. ${WmCmd}
  116.     
  117. Error message(s):
  118. ${ErrorMessage}
  119. "`
  120.     
  121.     elif test -n "${ErrorMessage}"; then
  122.  
  123.     ${LOCAL_BINPATH_xmessage}                    \
  124.         -title "${PROGRAM} warning:"                \
  125.         -name "${PROGRAM}-xmessage"                    \
  126.         -buttons OK -message                    \
  127. "${PROGRAM} warning - ${Wm} warning:
  128.  
  129. Command was:
  130. ${WmCmd}
  131.  
  132. Warning message(s):
  133. ${ErrorMessage}
  134. " &
  135.  
  136.     fi        # end of test ${ErrorCode} -ne 0
  137.     
  138.     if test "${Answer}" = "Quit"; then
  139.     exit ${ErrorCode};
  140.     fi
  141.     
  142. done
  143. -- 
  144. --
  145. Conrad Kimball       | Client Server Tech Services, Boeing Computer Services
  146. cek@sdc.boeing.com   | P.O. Box 24346, MS 7A-35
  147. (206) 865-6410       | Seattle, WA  98124-0346
  148.