LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-29-2006, 03:27 PM   #1
rutgerw
Member
 
Registered: Jun 2004
Location: Leiden, The Netherlands
Distribution: Slackware 10.2, SmoothWall Express v3, Kubuntu 7.04, Mac OS X.4
Posts: 69

Rep: Reputation: 15
Multiple instances of X using startx command


I know it's possible to start a second instance of X using the command
Code:
startx -- :1
. I wonder however if it could also be possible to start a second instance of X without the additional options, e.g. startx searches for the next available display. So if two users are logged in at the same time and both want to use X they do not need to hassle with the commands.

thnx
 
Old 07-29-2006, 03:56 PM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
I am not sure where to start but this is a thought. A script that checks to see if display :0 exist. If so then it uses the staxtx :1. Just not sure how to check to see if display :0 or so is active. This might give you a start or someone might continue on with this idea.

If I get some spare time I might look into it further.
Brian1
 
Old 07-29-2006, 03:57 PM   #3
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Try writing a wrapping script to find a free display:

NUM=$( ps auxwww | grep '\<X\>' | grep -v grep | sed -e 's/.* :\([0-9.]\+\)\( .*\)*/\1/' | sort -n | tail -1 | (read; echo $REPLY + 1 | bc ); );
startx :$NUM

If you really want to understand it all, read man bash, man sed, man grep, man tail, man sort. And know that bc is a calculator..

Or ask concrete questions

Last edited by raskin; 07-29-2006 at 04:01 PM.
 
Old 07-29-2006, 04:54 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by raskin
Try writing a wrapping script to find a free display:

NUM=$( ps auxwww | grep '\<X\>' | grep -v grep | sed -e 's/.* :\([0-9.]\+\)\( .*\)*/\1/' | sort -n | tail -1 | (read; echo $REPLY + 1 | bc ); );
startx :$NUM

If you really want to understand it all, read man bash, man sed, man grep, man tail, man sort. And know that bc is a calculator..

Or ask concrete questions
Just for kicks, I am trying this one piece at a time.
I gather that you are looking for all lines with "<X>" in them. On my machine (3 X-servers running) there are no such lines...

ps auxwww | grep '\<X\>' returns only one line:
mherring 8405 0.0 0.0 3912 660 pts/1 R+ 14:49 0:00 grep \<X\>

obviously this is what your script wants to delete (using grep -v grep)---then there would be nothing.

So maybe the syntax <X> is not always used??
 
Old 07-29-2006, 05:11 PM   #5
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
What grep do you have? I have (grep --version) 2.5.1 . If you have other version - replace \< by just < and \> by > . This means end-of-word in regexp.
 
Old 07-30-2006, 04:56 AM   #6
rutgerw
Member
 
Registered: Jun 2004
Location: Leiden, The Netherlands
Distribution: Slackware 10.2, SmoothWall Express v3, Kubuntu 7.04, Mac OS X.4
Posts: 69

Original Poster
Rep: Reputation: 15
Perhaps I could be a bit more concrete. If you edit for example your kdmrc file (when using kde of course) it is possible to have several 'reserve' Xservers. So when :0 is taken and you want to start up a new session the new session will be on :1. I would like to have the same behavior when starting X from the command line using the startx command. Does anyone know a config file I need to edit for this behavior?

regards
 
Old 07-30-2006, 09:01 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by raskin
What grep do you have? I have (grep --version) 2.5.1 . If you have other version - replace \< by just < and \> by > . This means end-of-word in regexp.
I also have 2.5.1---Now I realize what /< and /> are supposed to be doing: You are looking for "X" by itself--right?
When I do ps auxwww, this does not occur.

I have a hunch that these are the lines you are trying to find:

Code:
root      2477  2.6  1.7  23916 17716 tty7     Ss+  Jul29  21:13 /usr/bin/Xorg :0 -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
root      2524  0.0  0.4  10756  5104 tty9     Ss+  Jul29   0:01 /usr/bin/Xorg :1 -audit 0 -auth /var/gdm/:1.Xauth -nolisten tcp vt9
root      2548  1.3  1.8  25696 18872 tty10    Ss+  Jul29  10:52 /usr/bin/Xorg :2 -audit 0 -auth /var/gdm/:2.Xauth -nolisten tcp vt10
 
Old 07-30-2006, 10:52 AM   #8
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
No config file I know of. The above help from others for finding a running X server display is a start. Once one determines whether :0 is active, then ones will start :1. What one would do is create a script called lets say startxx. It will run a check (like using the above command like others above have provided) to see if :0 is active if it is it will then check for :1 and so on. Now if :1 is not active then it will issue the command startx :1 like you want. I am not great at scripts but maybe again others can help or study up on simple scripting and write your own. If I get time again I may work on this.

Brian1
 
Old 07-30-2006, 11:28 AM   #9
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Oops. Pixellany, in your case I would just substitute Xorg for X and have no problems. Just your distro makes this other way than my scripts in LFS system..
 
Old 07-30-2006, 03:58 PM   #10
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Got time to look this over and review the above post and command there Raskin. Looks good and works here. I can issue the command and then do a echo $NUM and shows what $NUM will be. Started a second display and run the command and it showed the value to be 2 since display 0 and 1 were active.
Code:
NUM=$( ps auxwww | grep '\<X\>' | grep -v grep | sed -e 's/.* :\([0-9.]\+\)\( .*\)*/\1/' | sort -n | tail -1 | (read; echo $REPLY + 1 | bc ); );  echo $NUM
Simply from here on out. Thanks for the info.

Brian1
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple instances of artsd Mojojo Linux - Software 0 10-13-2005 11:41 AM
SAMBA: Multiple Instances? Matir Linux - Software 0 02-18-2005 10:43 AM
Multiple instances of PHP cubax Linux - Newbie 6 12-30-2004 08:04 PM
Mplayer and Multiple instances Spaz007 Linux - Software 0 09-16-2004 10:59 PM
multiple instances of processes? ararag Linux - Software 2 07-31-2004 10:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration