5.7 Desktop Environments

Contributed by Valentino Vaschetto.

This section describes the different desktop environments available for X on FreeBSD. A ``desktop environment'' can mean anything ranging from a simple window manager to a complete suite of desktop applications, such as KDE or GNOME.

5.7.1 GNOME

5.7.1.1 About GNOME

GNOME is a user-friendly desktop environment that enables users to easily use and configure their computers. GNOME includes a panel (for starting applications and displaying status), a desktop (where data and applications can be placed), a set of standard desktop tools and applications, and a set of conventions that make it easy for applications to cooperate and be consistent with each other. Users of other operating systems or environments should feel right at home using the powerful graphics-driven environment that GNOME provides.

5.7.1.2 Installing GNOME

The easiest way to install GNOME is through the ``Desktop Configuration'' menu during the FreeBSD installation process as described in Section 2.9.12 of Chapter 2. It can also be easily installed from a package or the ports collection:

To install the GNOME package from the network, simply type:

    # pkg_add -r gnome

To build GNOME from source, use the ports tree:

    # cd /usr/ports/x11/gnome
    # make install clean

Once GNOME is installed, the X server must be told to start GNOME instead of a default window manager. If a custom .xinitrc is already in place, simply replace the line that starts the current window manager with one that starts /usr/X11R6/bin/gnome-session instead. If nothing special has been done to configuration file, then it is enough to simply type:

    % echo "/usr/X11R6/bin/gnome-session" > ~/.xinitrc

Next, type startx, and the GNOME desktop environment will be started.

Note: If a display manager, like XDM, is being used, this will not work. Instead, create an executable .xsession file with the same command in it. To do this, edit the file and replace the existing window manager command with /usr/X11R6/bin/gnome-session:

    % echo "#!/bin/sh" > ~/.xsession
    % echo "/usr/X11R6/bin/gnome-session" >> ~/.xsession
    % chmod +x ~/.xsession

Another option is to configure the display manager to allow choosing the window manager at login time; the section on KDE details explains how to do this for kdm, the display manager of KDE.

5.7.1.3 Anti-aliased fonts with GNOME

While anti-aliased fonts made their first appearance on XFree86 desktops in the KDE environment and are supported there in the standard installation, it is also possible to use them with GTK applications such as the GNOME environment. The most straightforward way is probably by using the libgdkxft library, in the x11/gdkxft port. After installing this port, read the /usr/X11R6/share/doc/gdkxft/README file carefully.

Then, all that is needed is to tell GTK applications to look for their font-rendering functions in libgdkxft.so before looking in the standard place, libgdk.so. This is easily accomplished by setting an environment variable to point to the right place; with the Bourne shell (/bin/sh) or similar shells, type the command (to start The Gimp, say)

    % LD_PRELOAD=/usr/X11R6/lib/libgdkxft.so gimp

and with csh and similar shells, type

    % setenv LD_PRELOAD /usr/X11R6/lib/libgdkxft.so
    % gimp

Or, the commands

    LD_PRELOAD=/usr/X11R6/lib/libgdkxft.so
    export LD_PRELOAD

can be put into .xinitrc, .xsession or in the appropriate place(s) in /usr/X11R6/lib/X11/xdm/Xsession, depending on how X is normally started. However, this short-cut may cause problems if Linux GTK binaries are run.

5.7.2 KDE

5.7.2.1 About KDE

KDE is an easy to use contemporary desktop environment. Some of the things that KDE brings to the user are:

  • A beautiful contemporary desktop

  • A desktop exhibiting complete network transparency

  • An integrated help system allowing for convenient, consistent access to help on the use of the KDE desktop and its applications

  • Consistent look and feel of all KDE applications

  • Standardized menu and toolbars, keybindings, color-schemes, etc.

  • Internationalization: KDE is available in more than 40 languages

  • Centralized consisted dialog driven desktop configuration

  • A great number of useful KDE applications

KDE has an office application suite based on KDE's ``KParts'' technology consisting of a spread-sheet, a presentation application, an organizer, a news client and more. KDE also comes with a web browser called Konqueror, which represents a solid competitor to other existing web browsers on Unix systems. More information on KDE can be found on the KDE website.

5.7.2.2 Installing KDE

Just as with GNOME or any other desktop environment, the easiest way to install KDE is through the ``Desktop Configuration'' menu during the FreeBSD installation process as described in Section 2.9.12 of Chapter 2. Once again, the software can be easily installed from a package or from the ports collection:

To install the KDE package from the network, simply type:

    # pkg_add -r kde3

To build KDE from source, use the ports tree:

    # cd /usr/ports/x11/kde3
    # make install clean

After KDE has been installed, the X server must be told to launch this application instead of the default window manager. This is accomplished by editing the .xinitrc file:

    % echo "exec startkde" > ~/.xinitrc

Now, whenever the X Window System is invoked with startx, KDE will be the desktop.

If a display manager such as xdm is being used, the configuration is slightly different. Edit the .xsession file instead. Instructions for kdm are described later in this chapter.

5.7.3 More Details on KDE

Now that KDE is installed on the system, most things can be discovered through the help pages, or just by pointing and clicking at various menus. Windows or Mac users will feel quite at home.

The best reference for KDE is the on-line documentation. KDE comes with its own web browser, Konqueror, dozens of useful applications, and extensive documentation. The remainder of this section discusses the technical items that are difficult to learn by random exploration.

5.7.3.1 The KDE display manager

An administrator of a multi-user system may wish to have a graphical login screen to welcome users. xdm can be used, as described earlier. However, KDE includes an alternative, kdm, which is designed to look more attractive and include more login-time options. In particular, users can easily choose (via a menu) which desktop environment (KDE, GNOME, or something else) to run after logging on.

To begin with, run the KDE control panel, kcontrol, as root. It is generally considered unsafe to run the entire X environment as root. Instead, run the window manager as a normal user, open a terminal window (such as xterm or KDE's konsole), become root with su (the user must be in the wheel group in /etc/group for this), and then type kcontrol.

Click on the icon on the left marked System, then on Login manager. On the right there are various configurable options, which the KDE manual will explain in greater detail. Click on sessions on the right. Click New type to add various window managers and desktop environments. These are just labels, so they can say KDE and GNOME rather than startkde or gnome-session. Include a label failsafe.

Play with the other menus as well, they are mainly cosmetic and self-explanatory. When you are done, click on Apply at the bottom, and quit the control center.

To make sure kdm understands what the labels (KDE, GNOME etc) mean, edit the files used by xdm.

Note: In KDE 2.2 this has changed: kdm now uses its own configuration files. Please see the KDE 2.2 documentation for details.

In a terminal window, as root, edit the file /usr/X11R6/lib/X11/xdm/Xsession. There is a section in the middle like this:

    case $# in
    1)
            case $1 in
            failsafe)
                    exec xterm -geometry 80x24-0-0
                    ;;
            esac
    esac

A few lines need to be added to this section. Assuming the labels from used were ``KDE'' and ``GNOME'', use the following:

    case $# in
    1)
            case $1 in
            kde)
                    exec /usr/local/bin/startkde
                    ;;
            GNOME)
                    exec /usr/X11R6/bin/gnome-session
                    ;;
            failsafe)
                    exec xterm -geometry 80x24-0-0
                    ;;
            esac
    esac

For the KDE login-time desktop background to be honored, the following line needs to be added to /usr/X11R6/lib/X11/xdm/Xsetup_0:

    /usr/local/bin/kdmdesktop

Now, make sure kdm is listed in /etc/ttys to be started at the next bootup. To do this, simply follow the instructions from the previous section on xdm and replace references to the /usr/X11R6/bin/xdm program with /usr/local/bin/kdm.

5.7.3.2 Anti-aliased Fonts

Starting with version 4.0.2, XFree86 supports anti-aliasing via its ``RENDER'' extension, and starting with version 2.3, Qt (the toolkit used by KDE) supports this extension. Configuring this is described in Section 5.5.3 on antialiasing X11 fonts. So, with up-to-date software, anti-aliasing is possible on a KDE desktop. Just go to the KDE menu, go to Preferences -> Look and Feel -> Fonts, and click on the check box Use Anti-Aliasing for Fonts and Icons. For a Qt application which is not part of KDE, the environment variable QT_XFT needs to be set to true before starting the program.

5.7.4 XFce

5.7.4.1 About XFce

XFce is a desktop environment based on the GTK toolkit used by GNOME, but is much more lightweight and meant for those who want a simple, efficient desktop which is nevertheless easy to use and configure. Visually, it looks very much like CDE, found on commercial Unix systems. Some of XFce's features are:

  • A simple, easy-to-handle desktop

  • Fully configurable via mouse, with drag and drop, etc

  • Main panel similar to CDE, with menus, applets and app launchers

  • Integrated window manager, file manager, sound manager, GNOME compliance module, and other things

  • Themeable (since it uses GTK)

  • Fast, light and efficient: ideal for older/slower machines or machines with memory limitations

More information on XFce can be found on the XFce website.

5.7.4.2 Installing XFce

A binary package for XFce exists (at the time of writing). To install, simply type:

    # pkg_add -r xfce

Alternatively, to build from source, use the ports collection:

    # cd /usr/ports/x11-wm/xfce
    # make install clean

Now, tell the X server to launch XFce the next time X is started. Simply type this:

    % echo "/usr/X11R6/bin/startxfce" > ~/.xinitrc

The next time X is started, XFce will be the desktop. As before, if a display manager like xdm is being used, create an .xsession, as described in the section on GNOME, but with the /usr/X11R6/bin/startxfce command; or, configure the display manager to allow choosing a desktop at login time, as explained in the section on kdm.

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.