From: rsmith@pioneer.arc.nasa.gov (Roger Smith RCS)
Newsgroups: fj.mail-lists.x-window
Subject: Re: How do I Start Screen : 0.1
Date: 26 Sep 92 12:13:18 GMT
Distribution: fj
Organization: RIACS, NASA Ames Research Center

Date: 25 Sep 92 21:36:17 GMT
Message-Id: <1992Sep25.213617.24232@riacs.edu>
Newsgroups: comp.windows.x

Recently I have seen quite a few questions regarding workstations
with multiple screens and how to start the Xserver so both screens
are active and logically connected, i.e., when the mouse is moved 
past the border of a screen it automatically appears on the adjacent
screen.

Its been a while since I set up many of our local workstations, but
I'll try to get the following right as pertains to Sun Sparcs running
the Xsun server which is invoked by xdm.

First of all the man page for Xsun describes the autoconfigure process
that Xsun performs:
     "... If a
     specific framebuffer device file isn't specified on the com-
     mand line with the -dev switch, the server will look for the
     following framebuffers (the constype(1) program may be  used
     to tell which type of display is attached as the console):

     /dev/bwtwo0
		...
     /dev/cgtwo0
		...
     /dev/cgthree0
		...
     /dev/cgfour0
		...
     /dev/cgsix0
		...
     Finally, if no specific framebuffers are found, the  generic
     framebuffer interface /dev/fb is used."

So, a quick check of /dev shows the following "special device" files:
	bwone0
	bwtwo0
	cgeight0
	cgfour0
	cgnine0
	cgone0
	cgsix0
	cgthree0
	cgtwelve0
	cgtwo0
	console
	des
	drum
	dump
	eeprom
	fb
and a look at the /var/adm/messages file from the last reboot shows:

	Sep 10 17:02:39 proteus vmunix: cgthree0 at SBus slot 1 0x0 pri 7
	Sep 10 17:02:39 proteus vmunix: cgsix0 at SBus slot 2 0x0 pri 7

and running the constype program in the console window after the xsession
has been started returns:

	cg3

This helps identify which physical screen is the cgthree0 referenced above.
The other screen is obviously the cgsix0 (for info only... really doesn't
matter).

Now, the file /usr/lib/X11/xdm/Xservers contains one line:

	:0 local /usr/bin/X11/X

which is a link to /usr/bin/X11/Xsun (assuming you are running the Xsun
server).

Lastly, here is the generic .xsession file which resides in each users
home directory (for those users with two screens):
-----------------------clip here-----------------------
#! /bin/csh
# remember, when first setting up this file, dont put anything in the background
# until after debug is finished. Then put it all in the background.

echo starting .xsession at `date` >> xlog
set cpu = `hostname`
echo cpu = $cpu >> xlog
echo DISPLAY = $DISPLAY >> xlog
switch ("$DISPLAY")
        case ":0"
                setenv DISPLAY $cpu$DISPLAY
                breaksw
        default:
                breaksw
endsw
echo after first switch DISPLAY = $DISPLAY >> xlog
### Allow access from the following hosts
xhost +george.arc.nasa.gov
xhost +franklin.arc.nasa.gov
xhost +pegasus.arc.nasa.gov
xhost +pioneer.arc.nasa.gov
xrdb -l .xrdbload
xrdb -m .Xdefaults
twm &
switch ("$DISPLAY")
        case "proteus.arc.nasa.gov:0"
                set display = $DISPLAY
                setenv DISPLAY $DISPLAY\.0
                setenv DISPLAY1 $display\.1
                breaksw
        case ":0.0"
        case ":0.1"
                setenv DISPLAY $cpu$DISPLAY
                echo DISPLAY = $DISPLAY >> xlog
                breaksw
        default:
                breaksw
endsw
echo DISPLAY finally = $DISPLAY >> xlog
echo DISPLAY1 finally = $DISPLAY1 >> xlog

                xload -g 195x97+0+800 -hl red -jumpscroll 1&
                rsh franklin -n /usr/bin/X11/xload -g 195x97+0+700 -hl red \				-jumpscroll 1 -d $DISPLAY &
                rsh pioneer -n /usr/bin/X11/xload -g 195x97+0+600 -hl red \
			-jumpscroll 1 -d $DISPLAY &
                rsh george -n /usr/bin/X11/xload -g 195x97+0+500 -hl red\ 
			-jumpscroll 1 -d $DISPLAY &
                xcpustate -g 280x22+0+476 &
                xset c 50

                xman -g 128x97+0+699 -d $DISPLAY1 &
                xbiff -g 50x50+0+644  -d $DISPLAY1 &
                rsh pioneer -n dxclock -g 150x97+0+798 -d $DISPLAY1 &
                xcalc -iconic  -d $DISPLAY1 &
xset c 50
xset m 3 5
$HOME/.start_sessions
exec /usr/bin/X11/xterm -title Console -font 6x10 -iconic -C\
	 -geometry 80x24+0+290 -name console -xrm "*iconGeometry:+0+521" -ls
------------------------end of .xsession-------------------------------------

Note the reference to the "xlog" file. Here is a "tail" of that file:

	starting .xsession at Fri Sep 11 10:20:10 PDT 1992
	cpu = proteus.arc.nasa.gov
	DISPLAY = :0
	after first switch DISPLAY = proteus.arc.nasa.gov:0
	DISPLAY finally = proteus.arc.nasa.gov:0.0
	DISPLAY1 finally = proteus.arc.nasa.gov:0.1
	hostname = proteus

In other words, the .xsession file sets up a comprehensive desktop
environment using both screens and leaves in the users environment
the variables DISPLAY and DISPLAY1 for ease of future reference. The
start_sessions file is reserved for the setup and placement of xterm's
on various hosts.

For those of you who don't want the mouse to move from screen to screen 
when crossing borders, use the following command line in 
/usr/lib/X11/xdm/Xservers:

:0 local /usr/bin/X11/X -zaphod

note that using the -zaphod option disables mouse switching between screens
so you will now have to rely on a window manager function to switch
between screens.

CAVEATS:
Read the man page for Xsun.  It gives the order in which frame buffers
are searched for and describes some exceptions and how to deal with
them. It also describes how to run the Xsun server for two or more
displays using Sunwindows and NeWS.

If you crash the server it often leaves the keyboard in an indeterminate
mode. Fixing this requires running "kbd_mode -a" as root.

Hope this helps.
------------------------------------------------------------------
Roger Smith
Sterling Software at
NASA-Ames Research Center
rsmith@proteus.arc.nasa.gov
- 
If change is -- inevitable -- predictable -- beneficial -- 
doesn't logic demand that you be a part of it?
One man cannot summon the future. But one man can change the present!
    -- Kirk and the Alternate Spock, "Mirror, Mirror," stardate unknown
+