My Linux Gaming Setup

"It isn't sexy, but that's not the point!"

[Screenshot] This screenshot shows XQF in action when using this setup. Too bad Q3A doesn't connect yet, and my life expectancy was very near 3 seconds in QuakeWorld DM servers... [2001-09-11]
[Screenshot] Plain, unadorned desktop. [2001-09-11]

Like many others, I use Linux for work, and Windows for playing most of the games - this just because most of the games come for Windows.

However, there are some cool games for Linux already. Loki has some nice games out there and coming up, and "that pesky Carmack guy" has made several rather cool first-person shooters that run on the OS.

Some cool Linux games - like Nethack, the unquestionably best CRPG - don't require any sort of changes to my normal gaming setup, because they don't require 3D support and run fine in windowed mode. (Nethack runs on everything. Everything.)

However, many new games use 3D graphics, and for that, I need a separate setup. Also, these games hog considerable amounts of machine resources. I run things like E-mail server, web server and web cache on my own machine - I don't need those when gaming.

Lightening the system

UNIXes have the concept of "run levels". This means that I can specify several modes of operation, and specific services are always available in those modes. There are also special runlevels, for things like maintenance and rebooting.

The program responsible for runlevels is called init.

My Debian system uses "System V" style init. This means that we have one directory under /etc that has start/stop scripts for various services, and then several directories which link to those scripts. When going to specific runlevel, init looks into the directory specific to that runlevel, looks at the name, and decides what to do with the service.

Debian is in runlevel 2 after the boot. Let's see what we have under /etc/rc2.d directory:

nighthowl:~# ls /etc/rc2.d/
S10sysklogd@     S20anacron@  S20makedev@     S20snort@        S50proftpd@
S11klogd@        S20cupsys@   S20mysql@       S20ssh@          S89atd@
S12kerneld@      S20gpm@      S20noffle@      S20ud@           S89cron@
S15netstd_init@  S20inetd@    S20postfix@     S30netstd_misc@  S91apache@
S18portmap@      S20logoutd@  S20postgresql@  S30squid@        S99rmnologin@
S20alsa@         S20lpd@      S20ppp@         S50junkbuster@   S99wdm@

Here, each file is named "XNNservicename", and is a symbolic link to /etc/init.d/servicename. init will take the name, and look at the first letter. If it's "S", the service will be started using the script in /etc/init.d. If the letter is "K", the service will be stopped with it. The number says in which order these scripts will be run; Here, sysklogd will be started first, and wdm will be started last.

I decided that I will use runlevel 2 for work, and runlevel 4 for games.

So, I just changed the names of the links in /etc/rc4.d:

nighthowl:/etc/rc4.d# ls
K20cupsys@      K20ssh@         S10sysklogd@     S20anacron@  S20snort@
K20gpm@         K30squid@       S11klogd@        S20inetd@    S20ud@
K20mysql@       K50junkbuster@  S12kerneld@      S20logoutd@  S30netstd_misc@
K20noffle@      K50proftpd@     S15netstd_init@  S20lpd@      S89atd@
K20postfix@     K91apache@      S18portmap@      S20makedev@  S89cron@
K20postgresql@  K99wdm@         S20alsa@         S20ppp@      S99rmnologin@

As you can see, most services that are not needed when gaming are calmly shut down. I don't need printer, database systems, or web cache...

Apparently, Debian doesn't have an interactive runlevel editor - or, rather, it does have one (rcconf), but it's rather primitive. It's easier just to rename the links manually.

Let there be graphics!

In work setup, I use wdm (WINGS display manager) to allow me to log to my GNOME / Window Maker environment. Of course, in default setup, X11 doesn't use DRI (the XFree86 4.x hardware-acclererated OpenGL interface), because that causes strange problems in some programs (blackenings, flickering) and may sometimes even completely freeze the system.

DRI modules are loaded in the bootup, by putting these to /etc/modules:

agpgart
r128

This will load the modules for AGP GART (don't ask me what that is, something to do with AGP bus that the card has been attached to, obviously =) and the DRI driver for my lousy no-good ATI Rage128 card.

Now, the DRI will not be loaded in /etc/X11/XF86Config-4, because of the instability issues mentioned earlier. Instead, I made an alternate XF86Config file that has the following differences:

The screen mode thing is just because I don't usually play with higher resolutions than that - no matter what sort of computer I have had, anything higher than 800x600 means certain death to FPS rate =) YMMV.

I placed this new configuration file to /etc/X11/XF86Config-4.games.

SM = Session Management

Now that we have an X display, we want something so that we can actually use it. Without further ado, I present you my xsession script, used to start all "start-up" programs and then the window manager:

#!/bin/sh

xsetroot -solid black
xloadimage -quiet -border black -center -onroot /home/wwwwolf/GameX/qpaper.jpg
/home/wwwwolf/bin/minibar &

exec /usr/X11R6/bin/twm

(All scripts and stuff I have related to this setup are in directory /home/wwwwolf/GameX.)

First, I load up a black background, and then load a background image. (It's just a Quake logo, found it from the net. I think it was part of some Quake theme for Windows.)

Then, we start up a small tool called minibar that displays a nice small launch bar. It doesn't appear to be packaged in Debian; You can get it from miniProject. (Thanks to Marcel for mentioning this in LJ, it was just what I was looking for...)

Then comes the thing that most people are afraid to look at: The window manager gets started. I chose twm.

For some reason, people don't find twm too sexy. Maybe because it isn't. However, it's a perfectly valid window manager for places that just can't use a "cool" window manager - I wouldn't hesitate to use it in a 386, or anywhere as the root's window manager. (r00t doesn't need a cool window damager! =) And I play the games in full screen, so question about window manager is fairly academic. Well, I suppose this gives more memory for the games...

Here's the startx script I use to launch my X session:

#!/bin/sh

ERRORLOG=/tmp/gamexsession-errors

if [ -e $ERRORLOG ]; then
	rm $ERRORLOG
fi

cd

/usr/X11R6/bin/startx \
    -T "Session" -e sh GameX/xsession -- \
    -xf86config XF86Config-4.games \
    	> $ERRORLOG 2>&1

This script will call the normal startx script that comes with X. On the first line after /usr/X11R6/bin/startx command, you can see parameters that are given to xterm. Basically, startx starts up an XTerm, and gives it title "Session", and runs our xsession script (from /home/wwwwolf/GameX/xsession). Those are the "client parameters". After the two dashes come the server parameters - only one: We want to use our game setup. After that comes just output redirection: All X messages should go to file /tmp/gamexsession-errors. Note that it only applies to X server messages; All applications that run in X print their messages to the "Session" XTerm.


[Index] [Up] [Main] [Weyfour WWWWolf]

Last modified: Tue Sep 11 02:12:44 EEST 2001