Keen in Linux
This page intends to be a complete tutorial on how to setup your Linux system to run Keen and other DOS applications. Therefor the DOS Emulator DOSBox is needed. Some distributions already include DOSBox in their installation media or online package repositories, but most likely it's an outdated version. In this Tutorial there are several ways shown on how to install and configure DOSBox on a Linux based machine (which is either by compiling, by installing via terminal or by installing via a graphical interface).
On a second note this tutorial discusses the compatibility layer tool WINE that aims to allow computer programs developed for Microsoft Windows to run on Unix-like operating systems. This comes in handy especially for modding tasks due to the fact that most Keen modding tools were written for Windows based operating system.
- 1 What you need
- 1.1 Setting up DOSBox
- 1.2 Mounting Keen's directory in DOSBox
- 1.3 Creating a shortcut to run Keen in DOSBox
- 1.4 Configuring DOSBox
- 1.5 Upscale Video Recordings
- 2 Setting up WINE
- 3 External Links
- 4 See also
What you need
- Obviously a working Linux distribution
- Any of the Commander Keen games (Originals/Mods).
- DOSBox itself (either via installing or by downloading the latest source code version at the official website.
- Optionally WINE to run Windows based modding tools.
If you get the latest version at DOSBox's website, you might need to install additional dependencies/development packages for building it from source code. The pro is you can get some machine-specific optimizations that may or may not improve DOS programs performance. The dependencies for version 0.70 are:
- GNU C/C++ compilers, GNU Make: provided by most distributions
- SDL library (+development package, see above): vital for DOSBox.
- SDL Sound (+development package): ?
- SDL Image (+development package): ?
- C/C++ development files
Setting up DOSBox
Download DOSBox' source code (should be a tarball named dosbox-X.Y.tar.gz, with X and Y the version numbers) and decompress it in any folder where you have read/write access with your regular user account. You can do it via a graphical user interface tool (such as Ark) or manually from a text Terminal (you'll have to use it anyway):
$ tar -zxvf dosbox-X.Y.tar.gz
That will decompress the package to the current directory. Then, you might want to check the README and INSTALL files provided in the DOSBox source root directory. You'll probably want complete optimizations, so just:
$ ./configure --enable-inline
To generate the makefiles. You can use any switches with configure if you need them, but don't forget to run configure.
Running make in the same directory the configure script is located at, will start the building process. At the end, assuming everything built successfully, you can do:
$ make install
And everything will install to the target directory provided by you (./configure --prefix=somedir) or the default (/usr/local). If you are installing DOSBox in /usr/local or any other directory where only root can write to, you'll have to
$ sudo make install
instead. If you don't know the root password (i.e., it is not your computer), you might have wanted to use the --prefix switch in the configure call, so that make install is performed in a directory of your user without root privileges. For example:
$ ./configure --enable-inline --prefix=$HOME
Installs DOSBox to your user home directory when doing make install, so the final DOSBox executable should be in $HOME/bin/dosbox.
Installing DOSBox via Terminal
Note: If you followed the steps above (i.e. built the program from its source code) skip this section.
Installing DOSBox in Debian/Ubuntu/LinuxMint via Terminal, you need to have root permissions. Open the Terminal and type:
$ sudo apt-get install dosbox
DOSBox will be installed in the ~/.dosbox tree.
Alternative you can install DOSBox via your Software-Center or Synaptic.
Dosbox is available on archlinux official repository.
$ sudo pacman -S dosbox
Installing DOSBox RPM package in RedHat via Terminal, you need to have root permissions. Just access the root account and install the RPM:
$ su rpm -i dosbox-X.Y.rpm
DOSBox will be installed in the /usr tree.
Mounting Keen's directory in DOSBox
Run DOSBox via Terminal by typing:
$ dosbox -c mount C /media/hdaY/somepath
Where -c (etc.) is for automatically mounting /media/hdaY/somepath (real directory) to DOSBox's drive C: (replace the C with any letter you want). After that, assuming you have KEEN.EXE in /media/hdaY/somepath, you just have to enter in DOSBox's command prompt:
Note: mods are getting started by calling their play.bat batch files.
Note: only mount directories which contain 8.3 filenames (8 letters filename, 3 letters extension) to avoid issues with your DOS-based programs.
Creating a shortcut to run Keen in DOSBox
To create a link in order to run a Commander Keen game in DOSBox, two files need to be created (Ubuntu/LinuxMint). One is a Shell-Script which mounts Keen's directory in DOSBox (seen above), the other one is a link for your Dash which calls this script.
Therefore open up your favourite editor (e.g. gedit, Kate, Mousepad, Leafpad) and type:
#!/bin/bash dosbox some/path/to/KEEN4E.EXE
The first line tells to execute the file using the shell. The second line calls DOSBox and mounts via the directory parameter the Keen executable into DOSBox. In this case the original KEEN4E.EXE is called. If you are going to link a mod, you might change this to
Play.bat or whatever the very batch file is named.
Save this as a Shell-Script with a distinctive name like
To make this script executable open up a terminal and type:
chmod +x /path/to/script/Keen4.sh
In a second step you need to create a Dash-link that calls this very script. Again open up an editor and type:
[Desktop Entry] Encoding=UTF-8 Name=Keen 4 Comment=DosBox + Commander Keen Type=Application Exec=/path/to/script/Keen4.sh Icon=/path/to/icon/or/image/Posion_Slug.png Categories=Game
Save this file under the path ~/.local/share/applications and name it
Keen4.desktop. Now you can open the game in DOSBox by simply typing
Keen4 into your Dash.
Depending on your system specs running Keen might be a straightforward step. However, having problems to run Keen (i.e. it lags, sound does not work, it needs more memory) there is a configuration file included in the
~/.dosbox folder (dosbox.cfg / dosbox.conf). Being a well documented file, you can open it with a text editor of choice and manually edit it to solve your very problem.
Mounting Games folder automatically
You can save yourself some time by having DOSBox automatically mount your folders and change the drive to C:. In original DOS-based operating systems a file called AUTOEXEC.BAT contained any commands that the user wanted executed every time the computer booted up. This functionality is simulated by the
[autoexec] section of the dosbox.conf file.
Browse into the
~/.dosbox/ folder and open the dosbox.conf. Then scroll down to the very end and add these lines:
MOUNT C ~/OLDGAMES C:
~/OLDGAMESis the path to your Keen games folder.
Alternative you can look for a GUI frontend called DOSBox Game Launcher (DBGL). Simply download this for your Linux version (32-/64-Bit), unpack it and move the extracted folder to
/opt/dbgl. To do this, use the Terminal and type:
sudo mv dbgl076_64bit /opt/dbgl
Create a link via the following command:
sudo ln -s /opt/dbgl/dbgl /usr/local/bin/dbgl
Now you can run the program by typing
If you want to stop the window from locking your cursor, look up
~/.dosbox/dosbox.conf for how to set
autolock=false. If you have games that you need to move your cursor to the edge of the screen, this can be annoying if autolock is off. You can always toggle it on or off using
ENTER to go into and out of full screen.
Alternatively, you can open the
~/.dosbox/dosbox.conf file as mentioned above and change
fullscreen=true. DOSBox will then run in full screen mode when you open it.
These are the default keybindings. They can be changed using the keymapper. Therefore open DosBox, press
F1 (or run it via Terminal:
dosbox -startmapper). Then map the keys to your liking.
|ALT-ENTER||Switch to full-screen (and back).|
|ALT-PAUSE (ALT-F16 on OS X)||Pause emulation.|
|CTRL-F1||Show the keymapper configuration screen,|
|CTRL-F4||Update cached information about mounted drives. Useful if you changed something on a mounted drive outside of DOSBox. Also cycles through disk images mounted using IMGMOUNT.|
|CTRL-F5||Save a screenshot (goes to |
|CTRL-ALT-F5||Start/Stop recording of AVI video. Attention: You may well have some problems with this, please see head to X-Server interception for more information.|
|CTRL-F6||Start/Stop recording sound output to a wave file (goes to |
|CTRL-ALT-F7||Start/Stop recording of OPL commands.|
|CTRL-ALT-F8||Start/Stop the recording of raw MIDI commands.|
|CTRL-F9||Kill (close) DOSBox.|
|CTRL-F10||Capture/Release the mouse (if you need to use the mouse within DOSBox).|
|CTRL-F11||Decrease DOSBox cycles slows down the emulation).|
|CTRL-F12||Increase DOSBox cycles speeds up the emulation).|
|ALT-F12||Unlock speed (turbo button).|
These default bindings are also documented in the README file accompanying the software.
Attention: by default, DOSBox’ video capturing feature is triggered by pressing
F5 simultaneously. Unfortunately this key combination will never reach DOSBox, as it will typically get intercepted by the X-Server and drop you to the 5th text console instead. It is recommended to change the combination for the video capturing through the method mentioned above.
Upscale Video Recordings
Upscale via Script
However, to customise the parameters more precise for your own needs plus keeping the output pixel perfect without any artifacts, an alternative way has to be chosen. This could be done by using a few Terminal commands.
First, get the FFmpeg codec from the official packages or type:
sudo apt-get install ffmpeg && sudo apt-get install libavcodec-extra
Next type into your terminal the following command:
ffmpeg -i in.avi -sws_flags neighbor+full_chroma_inp -s 1280x800 -r 30 -vcodec libx264 -crf 20 -acodec libmp3lame -aq 2 -f mp4 out.mp4
Change the parameter
in.avi to the path where DOSBox saves its video recordings, by default this is
Also change the parameter
out.mp4 to the a path of your choice (for example ~/myvideos/nameoftheoutputfile.mp4).
You can freely set the solution (here
1280x800). But it is recommended to use multiples of 320x200 (for example 640x400, 960x600, 1280x800...). Additionally you can choose the output container format. Here it is
mp4 (alternatives: avi, mkv...).
Finally run the command and wait until everything is done. This might take some time, depending on the source size and your system specs.
|in.avi||name and path of the source video you recorded with DOSBox|
|out.mp4||name and path of the output video destination|
|mp4||name of upscaled and muxed output container.|
|1280x800||the output solution in pixel. Multiples of 320x200 (for eg. 640x400, 960x600, 1280x800...)|
|sws_flags||controls the software scale|
|neighbor+full_chroma_inp||lets the scaler perform nearest neighbor interpolation and forces it to take the full input chroma resolution into account|
|-r 30||output frame rate|
|-vcodec libx264||determines the video encoder|
|-acodec libmp3lame -aq 2||codec for a variable bitrate mp3 stream|
|-aspect 4:3||set up a custom display aspect ratio to scale the video uniformly|
Setting up WINE
The compatibility layer tool WINE aims to allow computer programs developed for Microsoft Windows to run on Unix-like operating systems. This comes in handy especially for modding tasks due to the fact that most Keen modding tools were written for Windows based operating system.
It is also recommended to install PlayOnLinux, which is a graphical Windows and DOS program manager. It contains many scripts to assist the configuration and running of programs.
Installing WINE via Terminal
To install WINE in Debian/Ubuntu/LinuxMint via Terminal, you need to have root permissions. Open the Terminal and type:
sudo apt-get install wine
If you are running a 32-bit system make sure to also install the following:
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install wine32
To install PlayOnLinux use the following command:
sudo apt-get install playonlinux
Alternative you can install WINE via your Software-Center or Synaptic.
sudo pacman -Syu playonlinux
You can find the PlayOnLinux PKGBUILD in AUR.
Running modding tools via WINE
Most modding tools are standalone applications that can be run without the need for installation procedure. After installing WINE and PlayOnLinux most modding tools should run out of the box by simply double clicking the *.exe file.
Else you can manually install the an application via PlayOnLinux. Therefor open up PlayOnLinux and follow the programs installing procedure.
Running batch scripts via WINE
A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. Batch scripts can be detected by the *.bat extension. For e.g. most Keen mods come with a play.bat batch file which needs to be started to run the mod.
Once Wine is installed, open a Linux terminal/shell and run
wine cmd. This will open a separate Windows-Console window. From here, users can run various Windows terminal commands. Batch files can be run by typing
At this point, many Linux users may find it difficult to need to open a terminal and run that command just to run a batch file. Thankfully, there is a way to fix that problem.
The quickest fix is to add the line
alias winbatch="wine cmd /c " to the alias file
(~/.bash_aliases). Next, logout and log back in so that the alias file will re-initialize. Then, users can type
winbatch FILENAME.bat to execute a batch file in a terminal.
- FFmpeg Command Line Tools Documentation
- Detailed Article about Recording DOSBox and FFmpeg
- WINE homepage
- PlayOnLinux homepage
- Tutorial on running Windows batch files on Linux