Click to See Complete Forum and Search --> : Starting Games on a SECOND Xsession (eg virtual console F8)
DaHitman
07-21-2004, 10:50 PM
I thought I read an article a while back (dont remember the site) about someone who wrote up how to start your games up in a second x session on a different virtual console.
This would let you switch back to your desktop at the same time and keep the fullscreen game(like AA or UT) running on the other virtual console. I really wish I could switch back to a browser for a minute when I am playing AA.
It would be nice to be able to go to F7 and get my desktop and go back F8 to join the still running game.
Anyone remember this article or use a similar setup?
bburton
07-22-2004, 01:40 AM
I'm pretty sure GDM and KDM have the functionality for more than one X session built in. So I would refer to their respective manuals first.
But if you want to play with multiple X sessions, you can try this:
1. Start up X as normal
2. ALT-F1 and log in
3. Do a "X :1 &" (New plain X session should come up)
4. ALT-F1 back to terminal
5. Do a "xterm -display :1"
6. Go back to second X session by ALT-F8
7. Start up game/wm/whatever from xterm
Good luck.
timothykaine
07-31-2004, 05:12 AM
Originally posted by bburton
I'm pretty sure GDM and KDM have the functionality for more than one X session built in. So I would refer to their respective manuals first.
But if you want to play with multiple X sessions, you can try this:
1. Start up X as normal
2. ALT-F1 and log in
3. Do a "X :1 &" (New plain X session should come up)
4. ALT-F1 back to terminal
5. Do a "xterm -display :1"
6. Go back to second X session by ALT-F8
7. Start up game/wm/whatever from xterm
Good luck.
Is there a graphical tool for this, like the pager?
danimal1009
07-31-2004, 07:51 AM
That's a pretty cool trick, bburton. I've been wondering how to do that for quite some time.
lagitus
07-31-2004, 08:25 AM
In KDE you can use Ctrl+Tab to switch virtual desktops even if you are running a game. There might be some games with which this does not work though.
timothykaine
07-31-2004, 08:34 AM
Yeah I havent found a single game it works in yet. heh.
I found the best course of action is to just log into whatever window manager you normally use by default (in my case, KDE). Then just CTRL-ALT-F1.
startx -- :1 to open a second x session, then log into XFCE for my second one so it doesnt take resources in the background to run games. That... and XFCE is starting to grow on me...
Then of course I can CTRL-ALT-F7 / CTRL-ALT-F8 between them.
Are there any ups and downs to my being logged in on two WMs as the same user at the same time?
Things like trying to install an RPM in two places at the same time came to mind, I know I shouldnt do that, I just meant similar consequences.
t0t3r
08-08-2004, 07:26 AM
a script would be useful that starts the first X server with normal wm and apps and on the second X server just with a console ....
that if u type for example startx ..... both xservers start automatically!
any suggestions how to realize this?
bwkaz
08-08-2004, 01:41 PM
XF86CONFIG=XF86Config startx &
/bin/sleep 1 # Allow it to get the virtual console
XF86CONFIG=XF86Config-second-instance startx :1.0 With an /etc/X11/XF86Config file for the first instance, and an /etc/X11/XF86Config-second-instance for the second instance. If you don't need two separate config files, then remove the part that sets XF86CONFIG from both startx lines.
t0t3r
08-14-2004, 08:26 AM
hmm ... doesns't work! . I type in in first tty ... and cant switch on F7 and F8 ....
bwkaz
08-14-2004, 08:51 AM
Originally posted by t0t3r
and cant switch on F7 and F8 .... What do you mean? What are you doing when you try to do whatever this is referring to, and what happens?
t0t3r
08-14-2004, 02:45 PM
when i star a second x server from tty2 i can switch between 2 xservers on ctrl-alt-f7/f8 ........ thats what i mean!
bwkaz
08-14-2004, 07:18 PM
What does your script look like? Post it.
After running it, you'll be looking at the second X server. Ctrl-Alt-F7 to look at the first one (assuming your distro sets up only 6 virtual consoles for logging in, and doesn't dedicate any of the remaining ones to anything else, that is).
t0t3r
08-15-2004, 03:05 AM
no u got me wrong ....
how can i switch between the X-servers with ure script .... cause F7/F7 doesn't work.
bwkaz
08-15-2004, 01:36 PM
ctrl-alt-f7 and ctrl-alt-f8 will switch between virtual console 7 and virtual console 8. One X server should be running on each console.
Do you get any errors on the console that you ran this script from when it runs?
Try doing an export DISPLAY=:1.0 before starting a simple X program (like xterm) from the first X session. What error do you get, if any? If you don't get one, then the X server is definitely running, although it's possible that it isn't running on virtual console 8...
timothykaine
03-11-2005, 11:35 PM
Im bringing up a really old thread here, but I was wondering if there is anything you can add to the launch command on a game, so just starting the game automatically opens it on a second X server without having it run constantly?
lagitus
03-12-2005, 02:38 AM
How about something like this:
(X :1 &) ; (sleep 5s && export DISPLAY=":1" && start_the_game)
I used a ; instead of a && because this way the command will work even if X is already open on F8.
Btw. Does anyone know how to get the first unused virtual console?
Pafnoutios
03-12-2005, 08:59 AM
If the game you want runs fullscreen with it's own window management, you can initialize the X server with the game as the window manager as such:
xinit /usr/local/bin/nwn -- :1
This will start NeverwinterNights on display :1. I don't know how to set it to use the next available display if you already have more than one open. This doesn't use extra resources for a second window manager. I was able to Ctrl-Alt-F7/F8 back and forth. It only worked when I specified the absolute comand path '/usr/local/bin/nwn'. Although /usr/local/bin is in my path, if I just said 'nwn', all I got was KDE (my default WM). And the second X session is automatically shut down when nwn exits.
bwkaz
03-12-2005, 10:36 AM
Originally posted by lagitus
Btw. Does anyone know how to get the first unused virtual console? I'm pretty sure, though I'm not positive, that X does that by itself. ;)
If you don't explicitly specify a VT to run on, it cycles through them all until it finds one that's not in use.
There is also the openvt command, which is part of the "kbd" package. It will grab the first unused VT, and run the provided command on it. (You can also specify a specific VT if you need to. See the manpage for full usage details.)
However, I don't think openvt will work with X, because I don't think xinit runs on the same VT as the actual X server. You might be able to do something like openvt X :1, but I'm not sure what the point would be, since I believe X automatically chooses the first unused VT.
Pafnoutios
03-12-2005, 10:57 AM
The xinit program won't automatically use the first unused VT:
$ xinit /usr/local/bin/nwn
Fatal server error:
Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock
and start again.
Please consult the The X.Org Foundation support
at http://wiki.X.Org
for help.
retsaw
03-12-2005, 11:43 AM
Actually, all that proves is that it won't automatically use the first available display, it defaults to display ":0" and will error if an X server is using it and you therefore have to explicitly tell it to use display ":1" if ":0" is already in use, however that is different from a virtual console. You can tell X which virtual console to use with the "vtXX" option (where XX is the number of the virtual console you want to use), but it defaults to the first available virtual console if you don't.
Pafnoutios
03-12-2005, 12:32 PM
I see what you're saying. I've never thought of those as two seperate entities until now. I just had a :0=tty7, :1=tty8, ... type of vision.
I have a file somewhere on my system that assigns :1 to tty8 and :2 to tty9, etc.... It's used by the "Start New Session..." KDE menu option for user switching.
bwkaz
03-12-2005, 10:06 PM
So you want a way to find the first unused X display number?
Hmm... you could probably do that with some scripting and netstat. Something like:
#!/bin/bash
# ....
lastdisplay=$(netstat -anp | grep 0\\.0\\.0\\.0:60[01][0-9] | wc -l)
opendisplay=$(($lastdisplay+1))
xinit whatever -- :$opendisplay That is, assuming you have TCP sockets turned on in your X server's setup. (Display 0 is TCP port 6000, display 1 is port 6001, etc., etc.) If not, you can probably do something similar with Unix domain sockets, because I believe they all go in the same directory:
lastdisplay=$(ls /tmp/.X11-unix | wc -l)
opendisplay=$(($lastdisplay+1))
lagitus
03-13-2005, 04:49 AM
You could examine the lock files (/tmp/.X?-lock on gentoo) to see which one has the greatest number. Perhaps someone better with grep/awk/sed than I could make a script?
bwkaz
03-13-2005, 03:11 PM
Originally posted by lagitus
You could examine the lock files (/tmp/.X?-lock on gentoo) to see which one has the greatest number. True, but that counts almost the same thing as my second version above.
The difference is, /tmp/.X0-lock can be left behind by a crashed X server, while /tmp/.X11-unix/X0 can't be. (This is because when the X server's process dies (and stops listening on that socket), the socket disappears.)