home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / 20620 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  3.9 KB

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