[Wine] [tip] running games on a dedicated display

Philippe A futhark77 at gmail.com
Sat Jul 8 14:31:58 CDT 2006


Hi all,

Here's a small mechanism I have built to run games in a dedicated
display. The main reasons for doing that were:
- to avoid desktop stuff to pop over my games display
- to run games in a display matching the game resolution
- to avoid manually switching my main resolution back and forth
- to avoid problems where quitting a games leaves my desktop in the
wrong resolution

The idea is as follows. Each game has its own script (war3.sh,
starcraft.sh, etc), in which parameters to run the game are defined.
The game script calls winerun.sh, responsible of starting a new display
with the desired res and bpp and running the game. Common resolutions
and depths are defined in advance in /etc/X11/xorg.conf.

Here's what my war3.sh script looks like:

[snip]
#!/bin/sh

# Game parameters.
PROGRAM="c:/Program Files/Warcraft III/war3.exe -opengl"
SCREEN_RES="640x480" # Must match screen identifier in XF86Config
SCREEN_BPP="24"      # Must be defined for screen in XF86Config
GAMMA="1.75"

winerun.sh "$PROGRAM" $SCREEN_RES $SCREEN_BPP $GAMMA
[snip]

Here's the winerun.sh script. Feel free to tweak it to your liking (esp
mouse sensitivity).

[snip]
PROGRAM=$1
SCREEN_RES=$2
SCREEN_BPP=$3
GAMMA=$4

# Sensitivity works according to "xset mouse"
MOUSE_SENSITIVITY="1.15/15"
# Display number to use
DISPLAY_NUMBER=":1"
# Nice priority to give to wine. Note some games (ex Starcraft) do not
like -20.
PRIORITY=-10

# extract
APPDIR=${PROGRAM%/*}
APPEXE=./${PROGRAM##*/}

SCRIPT="xgamma -gamma $GAMMA
  xset mouse $MOUSE_SENSITIVITY
  cd \"$HOME/.wine/dosdevices/$APPDIR\"
  nice $PRIORITY wine $APPEXE $*
  wait"

# Run full screen on display 1.
export DISPLAY=$DISPLAY_NUMBER

# Make sure user is allowed to use display 1.
[ "`xauth list $DISPLAY_NUMBER`" ] || xauth add $DISPLAY_NUMBER .
`mcookie`

xinit /bin/sh -c "$SCRIPT" -- $DISPLAY -screen $SCREEN_RES -depth
$SCREEN_BPP
[snip]

And finally, here's how I defined resolutions and depths I want to be
able to use. Note how the screen identifier and depth values match the
game script parameters.

[snip]
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

Section "Screen"
    Identifier     "1024x768"
    Device         "Videocard0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       8
        Modes      "1024x768"
    EndSubSection
    SubSection     "Display"
        Depth       16
        Modes      "1024x768"
    EndSubSection
    SubSection     "Display"
        Depth       24
        Modes      "1024x768"
    EndSubSection
EndSection
[snip]

Using this is easy. Copy game.sh and winerun.sh in ~/bin. Add ~/bin to
your path. When you feel like playing, run game.sh. To setup a new
game, make a copy of game.sh and adapt it.

You can switch between your desktop and the game with the usual X
shortcuts:
CTRL+ALT+F7 accesses the desktop (display :0)
CTRL+ALT+F8 accesses the game display (assuming it stays on :1)
CTRL+ALT+F9 goes on :2
etc

Remember to mount the CD manually if needed, as the script does not
take care of that.

I have noticed some games fail to start with the script. It is the case
for Starcraft with my nocd loader (dlver-bw113floaderzip.zip+
dlver-miniscinstallzip.zip). In this case you have two choices: either
use your CD or run the game manually. I have refrained to report this
as a bug so far.

Also note that quitting a game thru its menus sometimes does not work
(happened more than once in Starcraft). In that case you can simply
make its display active and kill it with CTRL+ALT+BACKSPACE.

HTH



More information about the wine-users mailing list