Hello all,
I have found how to start display :1 with a regular user account to run a game into it. I have also an example script for running a game conviently. I have tested this on RedHat9.0 and it works nicely.
The following has been of great help to me:
http://bau2.uibk.ac.at/matic/xsecur.htm
mcookie manpage
This small howto is divided in 3 parts:
1- How to connect on X display 1
2- How to set set display 1 resolution and depth
3- How to automate game startup on display 1 with a script
Howto version : 2004-01-03
=== PART 1
=== How to connect on X display 1
The problem is typically the following. When opening a new display, it rejects connections with messages like the following:
Code:
$ xinit -- :1
AUDIT: Sat Jan 3 12:24:38 2004: 23447 X: client 1 rejected from local host
Xlib: connection to ":1.0" refused by server
Xlib: No protocol specified
his is because no authentication cookie has been created for the display. A cookie is a secret number used by the display to know who is authorized using it. The display only allows users knowing the secret number. Obviously, no one will ever be able to connect on display if no cookie is associated with it. A display without a cookie is a display on which it is impossible to connect. This is a basic security rule : to be hermetic by default.
The command below shows cookies exist for the display :0 only by default.
Code:
$ xauth list
phil/unix:0 MIT-MAGIC-COOKIE-1 b1b144b1ee50cd5dff484198ae19f99d
phil:0 MIT-MAGIC-COOKIE-1 b1b144b1ee50cd5dff484198ae19f99d
The solution is to create a cookie for the display prior to using it. It is as simple as that:
Code:
$ xauth add :1 . `mcookie`
The syntax is self explanatory except for the dot (.). The dot represents the authentication protocol we will be using. In RedHat9, this protocol is MIT-MAGIC-COOOKIE-1. Quoting the manpage: "A protocol name consisting of just a single period is treated as an abbreviation for MIT-MAGIC-COOKIE-1".
Then, opening the display will work right away:
By default, a cookie is automatically generated for the display :0 only. This explains why it is not possible to connect on new displays. It is OK to run "xauth add :1 . `mcookie`" everytime you want to use the display :1. You can also have the cookie created automatically for you everytime you open a graphical session on your system. All you have to do is to modify /usr/X11R6/bin/startx slightly. Look around line 130 for the following block of code.
Code:
[snip]
authdisplay=${display:-:0}
mcookie=`mcookie`
for displayname in $authdisplay $hostname$authdisplay; do
if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then
xauth << EOF
add $displayname . $mcookie
EOF
removelist="$displayname $removelist"
fi
done
[snip]
Edit the first line so it looks exactly like this:
Code:
authdisplay=${display:-:0 :1}
It will have the script create cookies for displays 0 and 1 the next time a graphical session is started. Logout/login and verify the change has taken effect:
Code:
$ xauth list
phil/unix:0 MIT-MAGIC-COOKIE-1 9d6b030498cbd20b6e3de6e198bcc52a
phil/unix:1 MIT-MAGIC-COOKIE-1 9d6b030498cbd20b6e3de6e198bcc52a
phil:0 MIT-MAGIC-COOKIE-1 9d6b030498cbd20b6e3de6e198bcc52a
Note our change to startx is quick and dirty. Our display 1 cookie wouldn't get created if the $display variable was set. I didn't find the case where this variable gets set.
=== PART 2
=== How to set set display 1 resolution and depth
I also found a neat way of starting display :1 with a specific bit depth and resolution.
As a first step, edit your /etc/X11/XF86Config file and add common resolutions you use for your games. Make sure each screen definition is given a unique Identifier string. For example:
Code:
Section "Screen"
Identifier "640x480"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 8
Modes "640x480"
EndSubSection
SubSection "Display"
Depth 16
Modes "640x480"
EndSubSection
SubSection "Display"
Depth 24
Modes "640x480"
EndSubSection
EndSection
Section "Screen"
Identifier "800x600"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 8
Modes "800x600"
EndSubSection
SubSection "Display"
Depth 16
Modes "800x600"
EndSubSection
SubSection "Display"
Depth 24
Modes "800x600"
EndSubSection
EndSection
When I play Starcraft, I open my display like this:
Code:
$ xinit -- :1 -screen 640x480 -depth 16
(Note Starcraft does not display anything when I use a 8bpp display)
Then, when I play Warcraft 3:
Code:
$ xinit -- :1 -screen 800x600 -depth 24
And so on!
=== PART 3
=== How to automate game startup on display 1 with a script
Finally, you can create a short script to start a game conveniently. I have saved the following script in /usr/local/bin and added this directory in my PATH. When I want to play Warcraft3, all I do is:
Copy this script and adapt it for every game you're playing.
Code:
[snip]
#!/bin/sh
GAME_PATH="/opt/winedir/c_drive/war3"
GAME_EXE="war3.exe -opengl"
SCREEN_RES="800x600" # Must match screen identifier in XF86Config
SCREEN_BPP="24" # Must be defined for screen in XF86Config
WINE_CMD="cd $GAME_PATH ; wine -- $GAME_EXE"
xinit /bin/sh -c "$WINE_CMD" -- :1 -screen $SCREEN_RES -depth $SCREEN_BPP
[snip]
Change GAME_PATH, GAME_EXE, SCREEN_RES and SCREEN_BPP according to your needs. When changing SCREEN_RES and SCREEN_BPP, make sure the corresponding res and depth and defined in your /etc/X11/XF86Config file.
Happy gaming!