Table of Contents
The X Window System is the graphical subsystem available for NetBSD and many Unix (and non Unix) systems. In fact it is much more than that: thanks to the usage of the X protocol, the X Window System is “network transparent” and can run distributed applications (client-server). This means, roughly, that you can run an application on one host (client) and transparently display the graphical output on another host (server); transparently means that you don't have to modify the application to achieve this result. The X Window System is produced and maintained by the X Consortium and the current release is X11R6. The flavour of X used by NetBSD is XFree86, a freely redistributable open source implementation of the X Window System.
Please note that the X Window System is a rather bare bones framework which acts again as a base for modern desktop environments like GNOME, KDE or XFCE, but they are not part of the X Windows System, and while NetBSD ships with the X Window System, it does not include these desktop environments. They can be added easily via the pkgsrc system, though, if needed.
When you start using X you'll find many new terms which you'll probably find confusing at first. The basic elements to use X are:
Video hardware supported by XFree86, i.e. your video card.
An X server running on top of the hardware. The X server provides a standard way to open windows, do graphics (including fonts for text display), and get mouse/keyboard/other input. X is network-transparent, so that you can run X clients on one machine, and the X server (i.e., the display, with video hardware) on another machine.
A window manager running on the X server. The window manager is essentially a special client that is allowed to control placement of windows. It also “decorates” windows with standard “widgets” (usually these provide window-motion, resizing, iconifying, and perhaps a few other actions). A window manager also may provide backdrops, etc. Window managers can also let you kill windows/programs by clicking on their windows, and so forth.
A desktop environment (optional.) KDE and GNOME, for example, are desktops: they are suites of more-or-less integrated software designed to give you a well-defined range of software and a more or less common interface to each of the programs. These include a help browser of some kind, a “desktop-metaphor” access to your filesystem, custom terminals to replace xterm, software development environments, audio, picture/animation viewres, etc.
Any other applications (3rd party X clients) that you have. These talk to the X server and to the window manager. Unless the window manager is part of the desktop (if any), the desktop probably doesn't get involved in much of anything that these applications do. (However, e.g., GNOME may be able to detect that you've installed the GIMP, for example, and so offer a menu to launch the GIMP.)
To summarize: in order to use a graphical environment you need
the XFree86 system
a window manager (XFree86 already comes with a very basic window manager called twm.)
If you prefer a more sophisticated environment you'll probably want to install a desktop too, although this is not necessary. Desktops have some nice features that are helpful to users who come from environments such as Macintosh or MS-WINDOWS (the KDE desktop, for example, has a very similar flavour to MS-WINDOWS.)
By now it should be clear that desktops like GNOME and KDE do not provide X servers. They run on top of an existing X server supplied by XFree86. KDE and GNOME can make use of their own window manager or of a separately installed window manager.
Normally, you can run at most one window manager at any given time on a given X server. (But you can run multiple X servers on a single computer.) If you are not running a window manager of your choosing, and start KDE/GNOME, then that desktop environment will run a window manager for you.
If you haven't chosen a minimal configuration during installation,
X is already installed and ready to run on your computer.
Depending on the exact hardware platform you run NetBSD and X
on, you may or may not need to configure your X server. While
most workstation ports (sparc, pmax, ...) will just work without
further configuration if you use the right X-server, which is
/usr/X11R6/bin/X is usually linked
On PCs (i386, amd64), Shark and some other platforms, you will
have to tune the X server first by create the menacing
To get an idea of what this file looks like, examine the
The structure of the configuration file is described formally
in XF86Config(5), which can be examined with the following
Before configuring the system it is advisable to carefully
documentation found in
there are various README's for the video cards, for the mouse and even
a NetBSD specific one (
I suggest to start by reading
You might have the feeling that other systems let you start more
quickly and with less effort, but the time spent reading this
documentation is not wasted: the knowledge of X and of your
configuration that you gain will turn out very useful on many future
occasions and you'll be able to get the most from your hardware
(and software too.)
You can create the
manually with an editor or you can generate it automatically with
an interactive configuration program.
The best known programs are xf86config,
XF86Setup (XFree86 3.x) and
xf86cfg (XFree86 4.x).
Both xf86config and xf86cfg are installed by default with X;
XF86Setup is a graphical configuration
tool which can be installed from pkgsrc.
You may find that a mixed approach is better: first create the XF86Config with one of the two programs and then check it and tune it manually with an editor. E.g. for the GUI based xf86cfg:
# configure to your will, and at the end save to /etc/X11/XF86Config
or for the screen-oriented, non-graphical xf86config:
# configure to your will, and at the end save to /etc/X11/XF86Config
The interface of the two programs is different but they both require the same set of information:
the mouse type and the mouse device to be used
the keyboard type and its layout
the type of video card
the type of monitor
Before configuring the system you should collect the required information.
The first thing to check is the type of mouse you are using (for example, serial or PS/2, ...) and the mouse device (for example, wsmouse requires a different protocol). If you are using a serial mouse, choose the required protocol and specify the serial port to which it is connected.
For example, PS/2 and USB mice usually are attached to the wsmouse device, and as such you can use:
Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "wsmouse" Option "Device" "/dev/wsmouse" EndSection
If you use a mouse with a scroll wheel, scrolling up and down is handled as mouse buttons 4 and 5 being pressed (respectively). Many applications like xterm or Firefox handle these button presses. To enable the scroll wheel, add the following lines to the "Pointer" section:
Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "wsmouse" Option "Device" "/dev/wsmouse"
Option "ZAxisMapping" "4 5"EndSection
For a serial mouse on the first serial port, try something like:
Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/tty00" EndSection
In this example.
/dev/tty00 is the first
serial port here, use
/dev/tty01 for the
second and so on. Protocol "auto" will try to automatically
detect the protocol of your serial mouse. If this doesn't work,
try values like "Microsoft", "ItelliMouse" or "Logitech", see
Even if you have already configured your keyboard for wscons, you need to configure it for X too, at least if you want to get a non US layout.
An easy solution is to use the XKB protocol, specifying the keyboard type and layout.
This is one area in which that configuration programs are weak and you may want to choose the standard layout and modify the generated configuration file manually:
Section "InputDevice" Identifier "Keyboard0" Driver "keyboard" Option "XkbRules" "xfree86" Option "XkbModel" "pc102" Option "XkbLayout" "de" Option "XkbOptions" "ctrl:nocaps" EndSection
If you want to use the “Windows” keys on your
keyboard, use “pc105” instead of
It is very important to correctly specify the values of the horizontal and vertical frequency of the monitor: a correct definition shields the monitor from damages deriving from an incompatible setup of the video card. This information can be found in the monitor's manual. In the X documentation directory there is a file containing the settings of many monitors; it can be used as a starting point to customize your own settings.
The video card can be chosen from the database of the configuration programs; the program will take care of all the needed setups. Video card support is slightly different between XFree86 3.x and 4.x.
XFree86 3.x has multiple servers for different categories
of video card chipsets. XFree86 4.x has only one server. Different video
chipsets are supported via platform independent driver modules,
which can be found in
When you have selected the correct video card you must choose the X server for the card. Usually, the configuration programs can automatically determine the correct server, but some video cards can be driven by more than one server (for example, S3 Virge is supported by the SVGA and S3V servers); in this case, study the documentation of the servers to decide which one you need: different servers usually have different capabilities and a different degree of support for the video cards.
When you exit the configuration program, it creates the file
/etc/X11/XF86Config, which can be further
examined and modified by hand.
Before starting X you should:
check that the symbolic link
/usr/X11R6/bin/X points to the correct X
ls -l /usr/X11R6/bin/X
Verify that the configuration is correct. Launch:
and examine carefully the output.
Now you can start X with the following command:
If X doesn't fire up there is probably some error in the configuration file.
If X starts but doesn't work as expected (for example, you can't move the mouse pointer) you can exit quickly with the Ctrl-Alt-Backspace key combination (not available on all ports). If everything worked correctly you are left in the X environment with the default window manager (twm): although it is a simple window manager many users feel that it is enough for their needs. If you want a highly configurable window manager with many bells and whistles, you have many choices in the package collection, see Section 9.9, “Other window managers” below.
To start customizing X, try giving the following command in an xterm to change the background color:
xsetroot -solid DarkSeaGreen
The look of the X environment can be customized in several ways.
The easiest method is to copy the default
.xinitrc file in your home directory and
modify it, or create a simple, new one from scratch.
cp /usr/X11R6/lib/X11/xinit/xinitrc $HOME/.xinitrc
The following example shows how to start the window manager (twm), open an instance of the xclock program in the lower right part of the screen and two xterm windows. The “Bisque4” color is used for the background.
The first part of the file is the same ... # start some nice programs twm & xclock -geometry 50x50-1-1 & xterm -geometry 80x34-1+1 -bg OldLace & xsetroot -solid Bisque4 & exec xterm -geometry 80x44+0+0 -bg AntiqueWhite -name login
With this type of setup, to exit X you must close the last xterm (the one with the “login” title - just type "exit" in it, e.g.).
Even with this simple configuration X has a considerably nicer look. To give an even better look to the environment you can install some utility program from the package collection. For example:
displays all the colors defined in
rgb.txt. Use it to choose background
colors for the root window or for xterms.
lets you use a pixmap for the background.
X screen saver.
no desktop can be complete without this package, which displays a moveable bitmap of the BSD daemon in two selectable sizes.
If you don't like twm, which is a very simple window manager lacking many features and not very configurable, you can choose another window manager from the package collection. Some of the most popular are: fvwm2, olwm/olvwm (Open Look Window Manager), WindowMaker, Enlightenment, AfterStep.
In the rest of this section the installation of
WindowMaker is described as an example.
WindowMaker is a very nice looking and highly configurable window
manager. To add the program the
windowmaker-0.60.tgz precompiled package
will be used, which depends on some other packages which must
be installed. As usual, both pkg_add and
make install will fetch the needed packages
automatically, so there is no need to go through the dependencies
make depends-listxpm-3.4k jpeg-6b pkglibtool-1.2p2 giflib-3.0 libproplist-0.9.1 tiff-3.5.2
You can also see the dependencies with the following command:
pkg_info -f windowmaker-0.61.0.tgz | grep depends
After adding the required packages, WindowMaker and some preconfigured themes can be added:
pkg_add windowmaker-0.61.0.tgz wmthemes-0.6x.tgz
WindowMaker is now installed; to start it you must modify your
substitute the line which calls
a line which calls
# start some nice programs # start WindowMaker wmaker & xclock -geometry 50x50-1-1 & xdaemon2 -geometry +0-70 & ...
In this example the xdaemon program is also started automatically.
Before starting WindowMaker the configuration program must be run:
In all the examples above, choosing “Quit” or
similar from the window manager's menu will quit the window
manager, but not log you out as you may expect. To do so, run
the window manager last and with no & in
... xclock -geometry 50x50-1-1 & xdaemon2 -geometry +0-70 & wmaker # no & here!
If you always use X for your work and the first thing you do after you log in is run startx, you can set up a graphical login for your workstation which does this automatically. It is very easy:
.xsession file in your home
directory. This file is similar to
~/.xinitrc and can, in fact, be a link
to the latter.
ln -s .xinitrc .xsession
xdm=YES xdm_flags="" # x11 display manager
If you prefer you can add the following line at the
/etc/rc.local instead of modifying
This method can be used to start, for example, kdm or gdm instead of xdm.
The configuration files for xdm
are in the
directory. In the
Xservers file X is
started by default on “vt05”, which is the console
you reach via “Ctrl+Alt+F5”; if
you want to use another virtual console instead, this is the
right place to modify the setting. In order to avoid keyboard
contention between getty and xdm it is advisable to start xdm on
a virtual terminal where getty is disabled. For example if in
Xservers you have:
:0 local /usr/X11R6/bin/X :0 vt04
/etc/ttys you should have
ttyE3 "/usr/libexec/getty Pc" vt220 off secure
(Please note that vt04 corresponds to ttyE3 because vt start at 1 and ttyE start at 0).
If you want a nice look for your xdm login screen, you can
modify the xdm configuration file.
For example, to change the background color you can add the
following line the the
xsetroot -solid SeaGreen
Instead of setting a color, you can put an image on the background using the xpmroot program: For example:
If you experiment a little with the configuration file you can achieve many nice looking effects and build a pleasing login screen. Note that other display managers like gdm and kdm offer different ways of configuration, usually GUI based.