Multiple X Sessions [was: Re: VAR Business story on SCO]

From: Bob Stockler (bob_at_trebor.iglou.com)
Date: 10/18/05


Date: 18 Oct 2005 16:34:48 -0400

Roger Cornelius wrote (on Mon, Oct 17, 2005 at 05:01:00PM -0700):

| Jean-Pierre Radley wrote:
| > Roger Cornelius typed (on Mon, Oct 17, 2005 at 11:52:12AM -0700):
| > | Bob Stockler wrote:
| > | > Roger Cornelius wrote (on Mon, Oct 17, 2005 at 09:58:37AM -0700):
| > | > | Bob Stockler wrote:
| > | > | > Will MP2 make possible more than one X session?
| > | > |
| > | > | It's already possible. Just supply an unused session number as an
| > | > | argument to startx. E.g., if you already have session 0, use:
| > | > |
| > | > | 'startx -- :1' (or 2, 3, etc.)
| > | > |
| > | > | Look in /dev/X to see what sessions are already active.
| > | >
| > | > Thanks, that works great!
| > | >
| > | > On OSR 5.0.6 I was used to just executing startx alone and it
| > | > would automatically pick the next available session number.
| > |
| > | Me too. I wrote my own script to determine the next session number,
| > | then exec the real startx with the necessary args.
| >
| > So would you contribute to the prevention of re-invented wheels? :-)
|
| What follows is basically what I use. I've excluded some non-relative
| stuff to select which window manager to use. It isn't perfect. E.g.,
| if you have servers 0 and 2 running, it will start server 3 rather than
| server 1. I doubt this would be a problem for anyone though. It also
| doesn't check to see if the serv3rs listed in /dev/X are actually
| running. Once, after rebooting when the machine hung, there were
| leftover entries in /dev/X. Again, that probably woudn't be a problem
| for anyone.
|
| I'm sure Bob can improve on this.

Thanks for the compliment (or was it a challenge?). Anyway . . .

#!/bin/ksh
# @(#) xstart - Start X using the lowest unused session number.
: ${AWK:=$(whence mawk)} ${AWK:=$(whence gawk)} ${AWK:=$(whence awk)}
eval $(
  ps -ef | $AWK '
  $8 ~ /^X/ { session[$9] = $9 }
  END {
    for (i=0;i<=10;i++) { ss = ":" i
      if ( session[ss] != ss ) { print "session=" ss ; exit }
    }
  }'
)
[[ $session = ":10" ]] && {
  print "\n All X sessions are in use.\n" ; exit
}
print "exec /usr/bin/startx -- $session"
exec /usr/bin/startx -- $session
# EOF xstart

Bob

| #!/bin/ksh
|
| # If an xserver is already running, start the next one
| # This was automatic with osr507 and earlier, but not OSR6
|
| startx_arg= # argument we pass to /usr/bin/startx, if
| any
| proto="/dev/X/server.*"
| set -A xs $proto # list of running X servers
|
| if [[ "${xs[@]}" != "$proto" ]]
| then
| # if server(s) already running, determine what next one s/b
| typeset -i n=${xs[${#xs[*]}-1]##*.}+1
| startx_arg="-- :${n}"
| fi
| unset n proto xs
|
| exec /usr/bin/startx $startx_arg

-- 
Bob Stockler  +-+  bob@trebor.iglou.com  +-+  http://members.iglou.com/trebor
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).


Relevant Pages

  • Re: Multiple X Sessions on OSR 6
    ... | Bob Stockler wrote: ... and command line startx fails with me in various ways. ... | session, X will start and give me the grey stippled background but no ...
    (comp.unix.sco.misc)
  • Re: Fact v Fishy
    ... what did he do that brought about such a sudden and tremendous change ... Brother Bob completely went the other way. ... it was during the whole year from session 1 to ... high level of creativity during that year. ...
    (rec.music.dylan)
  • Re: Fact v Fishy
    ... what did he do that brought about such a sudden and tremendous change ... mysterious when you look at the amount of material he would then ... Brother Bob completely went the other way. ... it was during the whole year from session 1 to ...
    (rec.music.dylan)
  • Re: Fact v Fishy
    ... mysterious when you look at the amount of material he would then ... Brother Bob completely went the other way. ... it was during the whole year from session 1 to ...
    (rec.music.dylan)
  • Re: Fact v Fishy
    ... mysterious when you look at the amount of material he would then ... Brother Bob completely went the other way. ... it was during the whole year from session 1 to ...
    (rec.music.dylan)