[comp.windows.x] dealing with multiple

salzman%gaucho@RAND.ORG (Isaac) (06/03/90)

There has been some recent discussion on this subject. For instance:

>crdgw1!montnaro@uunet.uu.net (Skip Montanaro) writes:
>
>The problems identified by Chris Quenelle (<9005291632.AA06491@ssiwest.com>)
>regarding LD_LIBRARY_PATH are only part of the problem related to multiple
>window systems on Suns. At GE CRD users can choose between Suntools, Quest
>X11R3, MIT X11R3, MIT X11R4, and Sun's OpenWindows. Some people (like
>myself) go back and forth between two or three of them with some regularity.

We have the same problem here. We run OpenWindows (various versions,
including very recent betas), MIT X11R4, Suntools, Sundesk (the suntools
OPEN LOOK deskset stuff), and (I hate to admit it) X10 (don't ask why).

I've set up something that's worked quite well for our environment. It's a
combination of csh aliases, shell scripts and a C program called 'setpath'.
Basically you 'source /usr/local/lib/xaliases.csh' in your .cshrc, type one
of 'x11', 'x11news', 'x10', or 'suntools' and you're off and running.

I've uploaded my scripts and 'setpath' to expo.lcs.mit.edu in
contrib/sun-xaliases.shar.Z. I'll eventually post this stuff to
comp.sources.x when I get an Imakefile for it and do some other cleaning
up. Included in the distribution are man pages for the scripts and aliases
and setpath, a README, INSTALL doc, and a text file describing the included
system.twmrc file (writing the manuals took longer than writing the
scripts! :-( 

The aliases hack your path's (PATH, LD_LIBRARY_PATH, MANPATH), set some
environment variables (e.g. XVERSION for the type of server you're
running), and run a script called 'xstart'. xstart looks at XVERSION and
other things to figure out what to do next. It eventually starts xinit with
the proper server arg's and uses a script 'xsetup' as the xinit client.
xsetup checks for one of several init files: .xsetup, .x1[10]setup,
.openwin-init, .xinitrc depending on what XVERSION is set to. A .xsetup
file is like a .xinitrc except that there's no 'last command' - xsetup
provides one for you (xterm -C ...). The purpose of that is to make .xsetup
more like a .suntools file, so people that are comming from suntools don't
go into culture shock. .xsetup will be read for MIT X11R4 or OpenWindows.
If you want seperate init files you can use .x11setup or .openwin-init. If
it finds a .xinitrc (and no .xsetup files exist) it will use that - and
behave just as if you typed 'xinit' - so people with already configured
environments (e.g. people who already know what they're doing) don't get
hosed. 

Besides dealing with the path problems, the scripts also provide a default
environment for first timers that have no dot files. A system.xsetup file
is read for that purpose - and you can put what you want in there (I have
an xterm, console xterm and twm - better than what 'xinit' alone gives).

The magic behind getting the path's setup properly is a little program I
hacked together called 'setpath' - inspired by a builtin function of the
CMU version of csh that comes with the MACH 2.0 distribution. It's used
like tset - with eval in backquotes. You can string up as many path edits
as you want in one command. If you're adding a path element (or inserting
it somewhere in the middle), it removes it first then adds it (to insure
ordering is as intended - and to avoid duplicates!!!). Here's an example of
how it's used in xaliases (you'll get the idea):

    alias setx11 'eval `setpath remove /usr/local/X10/bin '\
			'remove $OPENWINHOME/bin '\
			'remove $SUNDESK/bin '\
			'add +/usr/local/bin /usr/local/X11/bin'\
			'add -/usr/local/X11/bin $ANDREWDIR/bin' \
			'add -/usr/local/X11/bin $GUIDEHOME/bin'\
			'add -/usr/local/X11/bin $OPENWINHOME/bin/xview`; '\
		  'eval `setpath -e LD_LIBRARY_PATH '\
			'add +/usr/local/lib /usr/local/X11/lib '\
			'add -/usr/local/X11/lib $OPENWINHOME/lib` ; '\
		  'alias X x11; ' \
		  'setenv XVERSION X11' 
    alias _runx   '/bin/rm -f ~/,xerrs ; /usr/local/bin/xstart \!* >& ~/,xerrs'
    alias x11     'setx11; _runx'

there are similar aliases for x11news, suntools, etc.

If you play with the stuff I've uploaded to expo, please send e-mail and
let me know what you think. All suggestions, criticisms, etc. are welcome.
Enjoy!

--
* Isaac J. Salzman                                            ----     
* The RAND Corporation - Information Sciences Dept.          /o o/  /  
* 1700 Main St., PO Box 2138, Santa Monica, CA 90406-2138    | v |  |  
* AT&T      : +1 213-393-0411 x6421 or x7923 (ISL lab)      _|   |_/   
* Internet  : salzman@rand.org                             / |   |
* UUCP      : !uunet!rand.org!salzman                      | |   |