I'm sure many people know this already, but probably lots of people
don't.  You can have multiple people logged in with graphical displays
simultaneously.

E.g. to start up X on 2 displays, two users could log in on two text
consoles.  Then type "startx -- :0" on one, and "startx -- :1" on the
other, and use Ctrl-Alt-F7 and Ctrl-Alt-F8 to flip between them.  (By
default, Linux is set up so that F1-F6 are text consoles and F7-F12 are
graphical screens, so :0 is reached by Ctrl-Alt-F7 and :1 is reached by
Ctrl-Alt-F8.

In general, your run startx like:

        startx "client args" -- :$DISPLAY_NUMBER "server args"

Here's a script I wrote called "nextx" for finding the next available X
display.  You can use it like this:

        dnum=`nextx -v`
        startx -- :$dnum

luke
#!/bin/sh
#
# Determine the next available X display.
#

TMPF=/tmp/nx$$
if [ "x$1" = "x-v" ]
then
    verbose=echo
else
    verbose=":"
fi

#
# Output from ps ax, for X, should look something like:
#
# 1551 ?        S      0:02 /etc/X11/X :0 -bpp 16 -auth /home/stella/.Xauthority
#
# So we just grab the display number after the `:'.
#
ps ax | grep "/X " | grep -v grep | sed 's/.*\/X ://;s/ .*//' | sort -n > $TMPF

dnum=0
while [ $dnum -lt 4 ]
do
    read actnum
    if [ "$dnum" != "$actnum" ]
    then
        #
        # We've found the lowest display number not in use.
        #
        echo "$dnum"
        $verbose "Your displays will be: Text: Ctrl-Alt-F`expr $dnum + 1`" \
            ", Graphics: Ctrl-Alt-F`expr $dnum + 7`" >&2
        /bin/rm $TMPF
        exit 0
    fi
    dnum=`expr $dnum + 1`
done < $TMPF
/bin/rm $TMPF
echo "4 X displays already in use" >&2
exit 1

Reply via email to