The X Window System is a graphical environment 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 mantained 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.
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.
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 manager (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 destkop (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 window system
A window manager. XFree86 includes a nice, albeit simple, window called twm. There are more, and less, fancy window managers. Look in the pkgsrc ``wm'' (Window Manager) category.
If you prefer a more tightly integrated environment you'll probably want to install a desktop, 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.)
Note: 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; you only have to create the menacing /etc/XF86Config file. To get an idea of what this file looks like, examine the /usr/X11R6/lib/X11/XF86Config.eg file. The structure of the configuration file is described formally in XF86Config(4/5), which can be examined with the following command:
# man XF86Config
Before configuring the system it is advisable to carefully read the documentation found in /usr/X11R6/lib/X11/doc: there are various README's for the video cards, for the mouse and even a NetBSD specific one (README.NetBSD.) I suggest to start by reading QuickStart.doc. 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 /etc/XF86Config file manually with an editor or you can generate it automatically with an interactive configuration program. The best known programs are xf86config and XF86Setup. The former is a text mode program and is installed by default with X; the latter is a graphics program which can be installed from the package collection.
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.
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, for a serial mouse on the first serial port:
Section "Pointer" Protocol "Microsoft" Device "/dev/tty00" EndSection
For a mouse using the wsmouse device you might have:
Section "Pointer" Protocol "wsmouse" Device "/dev/wsmouse0" EndSection
In the "Device" field you can also specify /dev/mouse provided that you have created the correct link in the filesystem. For example:
# ln -sf /dev/wsmouse0 /dev/mouse
Even if you have already configured your keyboard for wscons, you need to configure it for X too, in order 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.
# XkbDisable # XkbKeymap "xfree86(us)" XkbModel "pc102" XkbLayout "de" XkbVariant "nodeadkeys"
If you want to use the "Windows" keys on your keyboard, use pc105 instead of pc102 for XkbModel.
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 automatic configuration programs; the program will take care of all the needed setups.
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 usualy have different capabilities and a different degree of support for the video cards.
When you exit the configuration program, it creates the file /etc/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 server:
# ls -l /usr/X11R6/bin/X
Verify that the configuration is correct. Launch:
# X -probeonly
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.
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. For example:
# cp /usr/X11R6/lib/X11/xinit/xinitrc ~/.xinitrc # vi .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.)
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.
In the package collection you can find a variety of window managers which you can use in place of twm, some with a limited set of features but a very small memory footprint, others with many fancy features (eg. virtual desktops, dithered window colors, etc.) 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 manually.
# cd /usr/pkgsrc/x11/windowmaker # make depends-list xpm-3.4k jpeg-6b pkglibtool-1.2p2 giflib-3.0 libproplist-0.9.1 tiff-3.5.2
Note: 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 .xinitrc and/or .xsession: substitute the line which calls twm with a line which calls wmaker. For example:
# 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:
$ wmaker.inst $ startx
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:
Create the .xsession file in your home directory. This file is similar to ~/.xinitrc and can, in fact, be a link to the latter.
xdm=YES xdm_flags="" # x11 display managerIf you prefer (why?) you can add the following line at the end of /etc/rc.local instead of modifying rc.conf:
/usr/X11R6/bin/xdmThis method can be used to start, for example, kdm or gdm instead of xdm.
The configuration files for xdm are in the /usr/X11R6/lib/X11/xdm directory. In the Xservers file X is started by default on the vt05 virtual terminal; if you want to use another terminal 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
in /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 Xsetup_0 file:
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.