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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-29-2006, 04:27 PM
|
#1
|
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:
|
Multiple instances of X using startx command
I know it's possible to start a second instance of X using the command
. 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
|
|
|
07-29-2006, 04:56 PM
|
#2
|
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:
|
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
|
|
|
07-29-2006, 04:57 PM
|
#3
|
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900
Rep:
|
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 05:01 PM.
|
|
|
07-29-2006, 05:54 PM
|
#4
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
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??
|
|
|
07-29-2006, 06:11 PM
|
#5
|
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900
Rep:
|
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.
|
|
|
07-30-2006, 05:56 AM
|
#6
|
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:
|
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
|
|
|
07-30-2006, 10:01 AM
|
#7
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
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
|
|
|
07-30-2006, 11:52 AM
|
#8
|
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:
|
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
|
|
|
07-30-2006, 12:28 PM
|
#9
|
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900
Rep:
|
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..
|
|
|
07-30-2006, 04:58 PM
|
#10
|
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:
|
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
|
|
|
All times are GMT -5. The time now is 01:18 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|