Difference between revisions of "Guide to FS Open on Linux"

From FreeSpace Wiki
Jump to: navigation, search
(SDL: undefined reference to...)
m (I18n and Key mapping problems: typo and charset problems)
Line 385: Line 385:
 
However, there is a solution. You can tell X to remap the keyboard before launching the game, and restore your normal keymap afterwards.
 
However, there is a solution. You can tell X to remap the keyboard before launching the game, and restore your normal keymap afterwards.
  
For exemple, I map 123456790 to the &é"'(-è_çà keys so I can use the communication system, and I put , and ; on the Alt-Gr and Menu keys for convenience, as I binded thoses keys to next primary weapon and next secondary weapon.
+
For exemple, I map 123456790 to &é"'(-è_çà keys so I can use the communication system, and I put , and ; on the Alt-Gr and Menu keys for convenience, as I binded thoses keys to next primary weapon and next secondary weapon.
  
 
To do this, I use a slightly enhanced startup script, which I put in ~/bin (this directory is in my path), together with a customized xmodmap.
 
To do this, I use a slightly enhanced startup script, which I put in ~/bin (this directory is in my path), together with a customized xmodmap.

Revision as of 22:21, 13 September 2006

This tutorial assumes some fundamental command line knowledge.
As a rule of thumb, do not copy/paste commands without understanding them, especially as root. With great power comes great responsability.

Installing CVS

CVS stands for Concurrent Versions System and is a version control system used to record the changes in documents, such as source files. Developers use CVS so they can easily share their code changes among other developers. You will need this tool to download ("checkout" in CVS terminology) fs2_open from the CVS server.

Debian/Ubuntu users want to:

$ apt-get install cvs

Gentoo users want to:

$ emerge cvs

Novell SuSE users install CVS via YaST.

NOTE: Redhat, Mandrake/Mandriva, Slackware and all the other distros should go here too, but we have no knowledge on how these work, so if you do, please enlighten us.

Installing the nessesary development libraries

You will also need SDL, OpenAL, libvorbis and OpenGL(most likely provided with your video card driver) development packages. And of course the GCC compiler and required make tools.
Debian/Ubuntu users want to:

$ apt-get install libopenal-dev libvorbis-dev build-essential automake1.9 autoconf libsdl-dev

NOTE: The build-essential meta package installs GCC4. This should work, but if you feel safer with GCC 3.4(gcc-3.4), add it to the apt-get line above.
Gentoo users want to:

$ emerge openal libvorbis libsdl

Novell SuSE users just install the mentioned packages and the devel-packages via YaST. If this works don't read further. SuSE maybe has some dependency problems with the game TORCS, i.e. its special version of OpenAL, so you have to make a choice. If you still want to run FS2 open, go on here http://www.hard-light.net/wiki/index.php/Fs2_open_on_Linux#Compile_Errors

NOTE: Redhat, Mandrake,Slackware and all the other distros should go here too, but we have no knowlage on how these work, so if you do, please enlighten us.

Installing game data files

This tutorial deals primarily with providing you with an executable, but in order to play the game you also need the game data. Freespace 2 game data is available from a number of sources, see this thread: http://www.hard-light.net/forums/index.php/topic,38195.0.html

Note that if you use the retail CD, you'll need to extract the files and to copy them on your drive, reproducing the same layout as in a working win32 installation (just make sure every file is lowercase). This thread on the SCP forum has some more info on it : http://scp.indiegames.us/forum_viewtopic.php?3.282

There are two ways of doing this :

  • use wine to install the game in the right directory, using the Setup.exe found on the first CD, or
  • extract manually the files from the cd.

The second method is detailed below. The wine one is straightforward and you shouldn't need any specific instruction, but you'll have to fix permissions and lowercase the filename as well, so keep reading.

Extracting data from CD

Installing unshield

First, you need unshield from http://synce.sourceforge.net/synce/unshield.php

If you use debian, apt-get install unshield as root should do the trick. Else, try to find a package for your distribution, or if you don't, compile it yourself following the instructions provided on the website. Note you don't need to actually install it, just compile it and use it from the directory where you compiled it.

Preparing directories

  • Create a directory for fs2_open, say, /usr/local/games/fs2_open, with a data/movies and data/players subdirectories. Everything but user files and configuration will be in this directory. You'll probably need to be root or use sudo for most of the following commands if you use a global directory like the one in this example.

Warning : Again, please double check the commands you run as root. A single typo could destroy your data. 'Remember what is said on the top of the page ? if not, go re-read it.

~ $ mkdir -p /usr/local/games/fs2_open/data/movies /usr/local/games/fs2_open/data/players

Extracting files

  • Use unshield to extract the groups from data1.cab (on the first cd) to a temporary directory; then move the files in your game directory :
~ $ mkdir /tmp/fs2
~ $ for group in "Basic Install Files" "Intel Anims" "Music Compressed" "High Res Files"; do unshield -d tmp/fs2/ -g "$group" -L -j x disk1/data1.cab && mv -v /tmp/fs2/*/* /home/data/jeux/fs2_open
~ $ unshield -d /usr/local/games/fs2_open/data/players -g "Hud Config Files" -L -j x data1.cab && mv -v /tmp/fs2/hud_config_files/* /home/data/jeux/fs2_open/data/players
  • From the second CD, get the vp files and the movies files (I dont think the the mve file are really needed, you'll need the avi ones if you want the movies).
~ $ cp -vf *.vp /usr/local/games/fs2_open
~ $ mkdir -p /usr/local/games/fs2_open/data/movies/ && cp -vf *.MVE /usr/local/games/fs2_open/data/movies/
  • Do the same for the third CD :
~ $ cp -vf *.vp /usr/local/games/fs2_open
~ $ cp -vf *.MVE /usr/local/games/fs2_open/data/movies/

You may notice that some files are on all three CD. This is because the games was meant to be run from CD. Don't bother.

Fixing Case and permissions

  • You have to make sure everything is lowercase :
~ $ find /usr/local/games/fs2_open/ | rename -v 'y/A-Z/a-z/'
  • Then, fix permissions :
~ $ find /usr/local/games/fs2_open -type d -exec chmod a+rx '{}' \;
~ $ find /usr/local/games/fs2_open -type f -exec chmod a+r '{}' \;

MediaVP and Cutscenes

You'll also need the mediavp from the SCP if you want the enhanced graphics. Get them at http://scp.indiegames.us. If you want the cutscenes, you'll have to find the avi version of the MVE files, or to convert them yourself. They are not hard to find. When you have them, just put them in the data/movies directory. Again, make sure everything is lowercase.

That's it for the game data files, now it's time get the source !

Using the source

CVS Checkout

Before you begin, make sure you have write permissions on your current working directory. Your /home/user/ directory is a pretty sure bet. I recommend that you create a permanent /home/user/src directory from which you run the CVS command, this way CVS will only update the files changed the next time you download the source and it's always nice to have things organized.

Now get the source. Run from a terminal:

$ cvs -d:pserver:anonymous:[email protected]:/home/fs2source/cvsroot login

and then

$ cvs -z3 -d:pserver:[email protected]:/home/fs2source/cvsroot co fs2_open

The first cvs command tells the CVS tool to first use a password file for authentication (pserver), that you are user "anonymous" with the password "anonymous" who wants to access warpcore.org's CVS repository "/home/fs2source/cvsroot" and login. The second command tells the CVS server on which we are now connected to that we want to checkout (co) the fs2_open module.

CVS Checkout and Update Script

The code on CVS is in a constant state of change, and bugs that exist one day may be gone the next. Because of this, you'll want to occasionally update to a newer version and recompile. Running those cvs commands will fast grow to be a pain, so this little script was created to make your life easier. This script will checkout fs2_open if it can't find a fs2_open directory and update fs2_open, if it finds it. The script will run until a successfull checkout or update has been achieved. Copy and save this to a suitably named file like "get_fs2_open", and make it executable with the command, chmod +x <name of file>

#!/bin/bash
# CVS Checkout and Update Script for fs2_open
CVS_LINE="cvs -d:pserver:anonymous:[email protected]:/home/fs2source/cvsroot" # The cvs command
if [ "$UID" = 0 ]; then # check if user is root, and if so, echo a warning.
	echo "You are root. If this is a checkout, all files \
	will be created with root as the owner."
	sleep 3
fi  
if [ -e ./fs2_open ]; then # check if directory fs2_open exists
	echo "Found fs2_open, We are updating an old checkout."
CVS_ATTEMPT=0 # This updates the checkout.
until [  $CVS_ATTEMPT = 1 ]; do
	$CVS_LINE login && \
	$CVS_LINE update fs2_open && \
	let CVS_ATTEMPT=1
done
else
	echo "No fs2_open found, This is a new checkout."
CVS_ATTEMPT=0 # This creates a new checkout.
until [  $CVS_ATTEMPT = 1 ]; do
	$CVS_LINE login && \
	$CVS_LINE co fs2_open && \
	let CVS_ATTEMPT=1
done
fi

Pre-Compile Configuration

Before you compile you need to configure it for your system. In the directory you ran the CVS command from, a new directory has appear, namely fs2_open. If your fs2_open is a completely new checkout, you will first need to run the autogen.sh script. Run from inside your newly created fs2_open directory:

$ ./autogen.sh

autogen.sh is a script that will generate the required makefiles. You will see alot of "checking for this" and "checking for that", this is actually the "configure" script (which can be run with ./configure if you need to change the options) examining and configuring fs2_open for your system.
It is possible to give autogen.sh configure options as well, autogen.sh will pass them along to configure.

A full list of configure options can be found by running the configure script with the '--help' option.

$ ./configure --help

Optimizing fs2_open

Optimizing fs2_open might have little or no effect, or improve performance greatly, I honestly have no clue.
A note of caution, if you are compiling a debug build, don't use the -fomit-frame-pointer CFLAG, it will make debugging impossible.
You can specify your compiler flags with the configure script, se below.

$ ./configure CFLAGS="<your desired flags>"

If you got a Athlon-XP and want to play it safe, a good set of CFLAGS would be

$ ./configure CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

You should read up on CFLAGS and what they do before trying anything. I recommend you read through these links.
http://gcc.gnu.org/onlinedocs/gcc-3.4.1/gcc/Optimize-Options.html
http://linuxreviews.org/howtos/compiling/safe-cflags/
http://en.wikipedia.org/wiki/CFLAGS

Compiling

Run from within your fs2_open directory:

$ make

Sit back and enjoy gcc work its magic.

Simple Compile Script

It's alot easier to use a scripts when dealing with constantly changing code. Copy and save this to a suitably named file like "compile_fs2_open", and make it executable with the command, chmod +x <name of file> This script assumes the CVS checkout directory fs2_open is pressent in the same directory as the script itself.

#!/bin/bash
# fs2_open Compile Script
# These are only examples, uncomment to enable optimization.
#MY_CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -ftracer"
if [ -e ./fs2_open/ ]; then
	cd fs2_open
	if [ -e ./Makefile.in ]; then
	make clean
	./configure CFLAGS="$MY_CFLAGS" CXXFLAGS="$MY_CFLAGS"
	make
	else
	./autogen.sh CFLAGS="$MY_CFLAGS" CXXFLAGS="$MY_CFLAGS"
	make
	fi
	else
	echo "No fs2_open directory found."
fi

You can add your options to the ./configure line.

Using the Binaries

When the compile is done and if all went well, a binary executable will reside in the code directory fs2_open_r or fs2_open_d if you configured for a debug build. Copy the binary to directory where Freespace2 is installed, and you're all set to go.

Post-Compile Configuration

Changing Your Resolution

Odds are, you'll want to run fs2_open in a higher resolution than the default 640x480. Unfortunately, we Linux users don't have the swank launcher app that the Windows folks do. Instead, we'll be making a couple line changes to a config file. You will need to run fs2_open once before you can make the necessary changes, otherwise you won't have a configuration directory to work with.

Open up ~/.fs2_open/fs2_open.ini with the text editor of your choice (vi, EMACS, kwrite, gedit). You'll see something like the following:

[Default]
VideocardFs2open=OGL -(640x480)x16 bit
LastPlayer=MonkeyboyS
GammaD3D=1.0

To set fs2_open to use the highest setting possible on retail Freespace 2, change the VideocardFs2open to:

VideocardFs2open=OGL -(1024x768)x32 bit

You can set this to pretty much anything you want.

Creating a Start Up Script

In order to use all of the advanced engine features of fs2_open, you'll need to start the executable with a number of command line arguments. Instead of typing them in every time you want to start the game, why not create a script that does it for you?

Create a new file named start_freespace (or whatever you like) in your home directory. Open the file in your editor of choice, and paste the following:

#!/bin/bash
cd /path/to/your/freespace/
./fs2_open_r -spec -glow -mipmap -jpgtga -orbradar -mod Media_VP

Note: You will need to edit this script before it will work properly. The second line must point to the directory where you installed fs2_open. You can also find a more elaborated script example below in the i18n section

The last line starts fs2_open with a number of arguments that turn on extra features. In the example, the game will use specular highlights, glow-mapping, mipmapping, jpg and tga graphic files, the orb radar, and any MediaVPs installed to the /Media_VP directory. You should edit this line to use those features that your system supports.

More information about the available Command Line Arguments can be found at the Command-Line Reference

Once you've edited the file to your heart's content, make it executable:

$ chmod +x start_freespace

You can now type in start_freespace to start the game, or by clicking on start_freespace in your window manager. For convenience, you can copy it to your Desktop.

See this for more command line options.

Advanced Startup Script

This is nothing fancy, but it's all the command line options in a file.

#!/bin/bash
#  Graphics
CMDLINE="-spec -env -glow -jpgtga -mipmap -2d_poof -missile_lighting"
CMDLINE="$CMDLINE -ambient_factor 75 -spec_exp 11 -spec_point 0.6"
CMDLINE="$CMDLINE -spec_static 0.8 -spec_tube 0.4"
#CMDLINE="$CMDLINE -pcx32 -cell -nomotiondebris -noscalevid -rlm -clipdist"
#  Game Speed
CMDLINE="$CMDLINE -cache_bitmaps"
#CMDLINE=$CMDLINE -img2dds -no_vsync"
#  HUD
CMDLINE="$CMDLINE -targetinfo -orbradar -ballistic_gauge -rearm_timer"
#CMDLINE="$CMDLINE -dualscanlines"
#  Gameplay
CMDLINE="$CMDLINE -ship_choice_3d -3dwarp -warp_flash -fov 0.39"
#CMDLINE="$CMDLINE -UseNewAI -tbp -wcsaga"
#  Audio
CMDLINE="$CMDLINE -snd_preload"
#CMDLINE="$CMDLINE -nosound -nomusic"
#  Multiplayer
#CMDLINE="$CMDLINE -standalone -startgame -closed -restricted"
#CMDLINE="$CMDLINE -multilog -clientdamage -mpnoreturn"
#  Troubleshooting
#CMDLINE="$CMDLINE -oldfire -nohtl -no_set_gamma -nomovies -noparseerrors"
#CMDLINE="$CMDLINE -safeloading -query_speech -d3d_bad_tsys -novbo -noibx -loadallweps"
#  Experimental
CMDLINE="$CMDLINE -alpha_env"
#CMDLINE="$CMDLINE -decals -ingame_join"
#  Development Tools
CMDLINE="$CMDLINE -fps"
#CMDLINE="$CMDLINE -pos -window -timerbar -coords -pofspew -tablecrcs -missioncrcs"
#CMDLINE="$CMDLINE -dis_collisions -dis_weapons -output_sexps"
#CMDLINE="$CMDLINE -output_scripting -nograb -show_mem_usage -stats"
#  Mod
CMDLINE="$CMDLINE -mod mv368zeta"
./fs2_open_r $CMDLINE

Troubleshooting

Compile Errors

Novell SuSE and the dependencies

If your SuSE gives you some errors like this, during the compile process, your OpenAL version is too old or corrupted.

sound/ds.cpp: In function 'int ds_init(int, int, unsigned int, short unsigned int)':
sound/ds.cpp:1790: error: invalid conversion from 'const char*' to 'const ALubyte*'
sound/ds.cpp:1790: error:   initializing argument 1 of 'ALboolean alIsExtensionPresent(const ALubyte*)'

You have to remove all OpenAL-packages via YaST, you may also want to remove TORCS, too, it won't run anymore after this. Unfortunately there is no repository with a newer version for this distro, yet, so you have to use a source-package for Fedora. You get it here http://download.fedora.redhat.com/pub/fedora/linux/extras/5/SRPMS/openal-0.0.9-0.6.20060204cvs.fc5.src.rpm The version may change, so you better check this. Now make sure, that TexInfo is installed. Then enter:

$ rpmbuild --rebuild --target=i686 <name-of-your-package>.fc5.src.rpm

If it builds without errors, you will find an OpenAL*.rpm and an OpenAL*-devel.rpm in /usr/src/packages/RPMS/i686/. Install both and go back to your fs_open directory again. Cause the environment has changed now, you better type:

$ make clean
$ ./configure [options]
$ make

Then you're done.

SDL: undefined reference to...

This is a SDL installing issue, since it's trying to link against the static lib and not the dynamic one. First check where /usr/lib/libSDL.so is linked to, then search this very file.

$ ls -l /usr/lib/libSDL.so
lrwxrwxrwx  1 root root 28 2006-09-06 00:10 /usr/lib/libSDL.so -> /usr/lib/libSDL-1.2.so.0.7.1
$ ls /usr/lib/ | grep libSDL-1.2.so.0.7
libSDL-1.2.so.0.7.2

If they are not the same (like in this case), you just make a new link. Type as root:

# ln -s /usr/lib/libSDL-1.2.so.0.7.2 /usr/lib/libSDL.so

Of course you must change some figures, so it matches on your system.

Missing -lGLU compile error

On some Linux distributions (Slackware for instance), compiling fails because a GL related library doesn't have a link in the /usr/lib directory. If the compile fails because it can't find -lGLU, here are two ways to fix it:

Solution as Root

If you have root access to the system, you can create a link to the library in question with just a little bit of command line magic. Go to a console and enter:

$ ln -s /usr/X11R6/lib/libGLU.so /usr/lib/libGLU.so

After that, you can run make again and it should finish compiling.

Solution as a Non-Root user

You don't have root access? Never fear, we can still fix the problem. It'll just be a tad more difficult.

Navigate to the fs2_open/code directory and locate a file named Makefile (not Makefile.rm or Makefile.in or Makefile.anything). Open it in your favorite text editor and make the following changes.

Find this line (line 457 in mine):

FS2_LDFLAGS =  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lGLU -lopenal -logg -lvorbis -lvorbisfile

And replace it with this:

FS2_LDFLAGS =  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lopenal -logg -lvorbis -lvorbisfile -L/usr/X11R6/lib -lGLU 


Also find this one (line 565 in mine):

AM_LDFLAGS =  -g  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lGLU -lopenal -logg -lvorbis -lvorbisfile

And replace it with this:

AM_LDFLAGS =  -g -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lopenal -logg -lvorbis -lvorbisfile -L/usr/X11R6/lib -lGLU

Then run make from the fs2_open directory, and watch the magic happen.

glBindBufferARB feature missing

If this is the actual solution to this problem remains to be seen.
So far, only people using Debian stable are affected by this.
So we need adventurus Debian users to confirm.
I can confirm that the APT-Pinning works, can not confirm compile thou. -- ni1s

checking for glBindBufferARB in -lGL... no
configure: error: *** OpenGL version does not have the required features!! (ie.glBindBufferARB()) ***

This error appears if the installed Mesa development library is to old.

On Debian stable branch the xlibmesa-gl-dev package holds version 4.3.0.
The xlibmesa-gl-dev package on testning is version 6.9.0.

Possible solution:
First set /etc/apt/sources.list to include the testing branch. Add:

#Testing
deb http://ftp.us.debian.org/debian testing main non-free contrib
deb http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free

Your sources.list might have these lines already, if so, you should be okej.

Your /etc/apt/preferences file should look like this

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=testing
Pin-Priority: 650

Package: *
Pin: release a=unstable
Pin-Priority: 600

Add to that file:

Package: xlibmesa-gl-dev
Pin: release a=testing
Pin-Priority: 800

Note that the Pin-Priority of xlibmesa-gl-dev here is higher than the Pin-Priority on 'stable'. As a result of this APT get will prioritize the xlibmesa-gl-dev from testing and leave the rest of the system on stable. This is called apt-pinning.

Now that APT knows what xlibmesa-gl-dev to prioritze, install it again:

$ apt-get install xlibmesa-gl-dev

If you are using nVidia's nvidia-kernel and glx packages, a simple:

$ apt-get install nvidia-glx-dev

should suffice. No need to mess around with APT-pinning.

Runtime Errors and common problems

ERROR: "Web cursor bitmap not found."

ERROR: "Web cursor bitmap not found.  This usually means that the executable is being run outside the  directory
you installed Freespace2 to.  Please move the executable to that directory and try again" at  graphics/2d.cpp:1402

A common error. This happens when fs2_open can't find the .vp files or that your user doesn't have the permissions to access them. If you are using a start up script(like the one found here) it's most likly the a permission problem. Have your user take owenership of the .vp files, run as root:

$ chown <user> /path/to/vpfiles/ -R

I18n and Key mapping problems

Me, being a Swede, need to use this aswell, especially for the grave key(`), but I also want to use a second X display. There is a way to tell xmodmap to use the new set of keys on the second X display, and thus eliminating the need for a temp. keymap table as it dies with the second display when exiting fs2_open, never touching the keymap table on display 0. We should dig that info up and write a super-start script. --ni1s

Ok, imagine that like me you don't have an us keyboard but a french one (or anything). Well, you probably have problems mapping some keys or even using the default mapping.

Actually, the problem is fs2_open does not take modifiers into account, as it uses them internally as modifiers for keys, and it won't accept non-us charset either.

On a french keyboard layout, the numbers 1 2 3 4 5 6 7 8 9 0 are on the same keys than on a US layout, but you have to press shift to use them. The primary function for theses keys are & é " ' ( - è _ ç à ). These characters won't be accepted by freespace, and if you press shift to get a number, it won't work. This can be a problem, as theses keys are needed to use the communication system, and cannot be bound to anything. Also, as you won't get access some keys on your keyboard, it will be difficult to map every command on a key, or you'll have to use modifiers for nearly each key.

However, there is a solution. You can tell X to remap the keyboard before launching the game, and restore your normal keymap afterwards.

For exemple, I map 123456790 to &é"'(-è_çà keys so I can use the communication system, and I put , and ; on the Alt-Gr and Menu keys for convenience, as I binded thoses keys to next primary weapon and next secondary weapon.

To do this, I use a slightly enhanced startup script, which I put in ~/bin (this directory is in my path), together with a customized xmodmap.

  • First, dump your current xmodmap :
 ~ $ xmodmap -pke > ~/xmodmap.current
  • Then edit it with your favorite text editor. You'll see a bunch of lines looking like this :

keycode   8 =
keycode   9 = Escape
keycode  10 = 1 ampersand onesuperior exclamdown onesuperior exclamdown

The syntax is keycode <number> = <symbol list>.

Use xev to scan the keycodes. The symbols are defined in /usr/include/X11/keysymdef.h. Just make sure you write them without the XK_ prefix. You'll find more information about xmodmap in the xmodmap manual page.

Just modify the keys you need, and be patient. This can be a long process. Test it with xmodmap :

 ~ $ xmodmap - < <filename>

But don't forget to have your previous keymap at hand to recover your settings ! If you mess everything up, just restart X. Your default keymap will be applied from the X configuration.

Here is my own fs2 xmodmap, derived from fr-latin1 as described above. Feel free to use it if you're too lazy to modify your own. However, it may not fit with your needs. You may always use it as an exemple, thougt.

Then, when the file is modified at your liking, just save it as ~/.fs2_open/xmodmap

We'll start fs2_open with a slightly more elaborate startup script which will backup/apply/restore the keymap in addition of running the games with some options in the right directory.

#!/bin/sh
# This script lauches fs2. If there is a file named $FS2_modmap (see below), 
# backup the current modmap as $TMP_modmap and load it as the new modmap. 
# The current modmap will be restored afterwards.

TMP_modmap="$HOME/xmodmap.tmp"
FS2_modmap="$HOME/.fs2_open/xmodmap"

FS2_OPEN_DIR=/usr/local/games/fs2_open

FS2_ARGS="-glow -spec -spec_exp 11 -spec_point 0.6 -spec_static 0.8 -spec_tube 0.4 -fps -jpgtga -ambient_factor 75 -targetinfo -nograb"

FS2_BIN="$FS2_OPEN_DIR/fs2_open_r"

die() {
    echo "** Fatal error : $1" >&2
    exit 1
}

cd $FS2_OPEN_DIR || die "Could not change directory to $FS2_OPEN_DIR"

# dump current xmodmap
[ -f "$FS2_modmap" ] && xmodmap -pke > $TMP_modmap

# load xmodmap
[ -f "$FS2_modmap" ] && xmodmap - < $FS2_modmap

# prepare to restore xmodmap on crash or exit
trap "xmodmap - < $TMP_modmap && rm $TMP_modmap" 0 2 3 4 9 11 15

# launch fs2
$FS2_BIN $FS2_ARGS $* || die "Error while running \"$FS2_BIN\" with arguments \"$FS2_ARGS\" ($?)" 

Adapt this script to your needs, and save it somewhere in your PATH - I for exemple usr ~/bin/freespace2. Make it executable with a chmod +x <file>

That's it, now you can use fs2 with full control over your keyboard.

fs2_open freezes X

A good way of running games on Linux is having them run on a separate X display. The display you are most likely using now when reading this is 0:0. This display is normally used for whatever Window Manager/Desktop Environment(KDE,Gnome,*box,E) you've chosen. Sometimes fs2_open freezes and locks your X. This is of course very annoying as you have to CTRL+ALT+BACKSPACE to kill the X server, and in that, killing whatever program you had running besides fs2_open. The solution to this is to tell X to start fs2_open on another display. To to this we first need to tell X that you,the user on localhost, holds the permission to run on another display. In a terminal, enter (NOT as root):

$ xauth list

A list that looks something like this should appear.

myuser@localhost ~ $ xauth list
localhost/unix:0  MIT-MAGIC-COOKIE-1  14ec70e7c8cc835def61a04c92bbd50d

Let's look at that line, first up is your localhost, then unix, and last the display number,:0 (in bold). The rest is not really of interest. Copy the whole line, but change the display value to 1 and paste it after the command xauth add, like this:

$ xauth add localhost/unix:1  MIT-MAGIC-COOKIE-1  14ec70e7c8cc835def61a04c92bbd50d

Run xauth list again. You should see a new entry.

myuser@localhost ~ $ xauth list
localhost/unix:0  MIT-MAGIC-COOKIE-1  14ec70e7c8cc835def61a04c92bbd50d
localhost/unix:1  MIT-MAGIC-COOKIE-1  14ec70e7c8cc835def61a04c92bbd50d

You now have permission to use display 1:0. To start fs2_open in that display, use xinit.

$ xinit /path/to/fs2_open_r -foo -bar -- :1

The -- :1 tells X that we want to start fs2_open on display 1.
You can switch between display 0 and 1 with CTRL+ALT+F7 and CTRL+ALT+F8 respectively.

If you try this from an xterm (or a similar X terminal program) and obtain the error X: user not authorized to run the X server, aborting., the reason might be the file /etc/X11/Xwrapper.config. On my ubuntu machine, it contains the line

allowed_users=console

which means that only users logged in from a console terminal may start a new X server. However, on an xterm, you are on a virtual terminal and so the above does not work. A possibility is to change the allowed_users in the Xwrapper.config file to "anybody" (see man Xwrapper.config). However, this undermines X security. Another possibility is to start the xinit command from a console window (to which you can change with CTRL+ALT+F1-6).

If someone knows of a good method to start fs2 on a second X display from an xterm without changing Xwrapper.config, please report it here.

A solution might be running xinit as root with sudo, and drop the root privileges in the startup script... Didn't tried, though. -- nodens