Chapter 16. Introducing the Graphical Environment

Table of Contents

Introduction
The Structure of X
The X Window System
Installing Xorg
Window Managers
Installing a Window Manager
Activating a Window Manager
Desktop Environments
GNOME
KDE
XFCE4
Activating a Desktop Environment
Logging on Graphically
Install Graphical Logon Manager
Setup the Default Graphical Environment
Supporting 3D Acceleration

Introduction

Linux is often seen as a command-only operating system. This is far from true: although its command-line is a powerful interface, you can also launch graphical environments on Linux. In this chapter, we briefly cover the graphical environments in Linux.

Graphical environments are the de facto standard for working with a workstation. Many users know the Microsoft Windows family or the Apple MacOS series. However, those two aren't the only providers of a graphical environment. When the Intel-compliant PCs were hardly known to the world, consoles and other personal computers already provided a graphical environment to their users.

It comes to no surprise to hear that the free software community also provides graphical environments. And, just like you have choice amongst distributions, you have choice amongst graphical environments: GNOME, KDE, XFCE4 are popular desktop graphical environments; enlightenment, fluxbox, window maker, icewm, ... are window managers.

Although most readers will be sufficiently fluent in using a graphical environment, this book wouldn't be complete if it didn't cover it. As such, and with the danger of being overly simple on the subject, this chapter will briefly cover the concept of graphical environments.

The Structure of X

On Linux, a graphical environment consists of many components:

  • Applications

  • Widget Tool Kits

  • Window Manager

  • X Server

  • Hardware

Each of those components interacts with others through specific interfaces.

Figure 16.1. A possible representation of how X is structured

A possible representation of how X is structured

An application is able to draw graphic components (buttons, windows, progress bars, labels etc.) through a common API called a widget tool kit. Popular widget tool kits on Linux are GTK+ and Qt. However, not all applications require a widget tool kit - they can also talk to the X server immediately. Using such tool kits however facilitates the development of graphical applications.

The widget tool kits communicate with the X server through an interface which basically drives all commands to a window manager. A window manager manages the layout of the users' screen: where are the windows positioned, can he drag windows from one location to another, how are buttons rendered, ... Popular window managers are Mutter (used by the GNOME desktop environment), KWin (used by the KDE desktop environment), fluxbox, enlightenment, ...

Most window managers are written for specific widget tool kits, but some of their functionality extends beyond one particular window manager: this allows window managers to support not only rendering of applications built with different widget tool kits, but also interoperability between these applications (copy/paste, drag 'n drop ...).

The window manager receives commands from the X server. The X server is responsible for turning requests into hardware-specific actions (draw window means to render a window through the graphic card, mouse movements are events coming from the mouse device and directed to the window manager to move the cursor, ...).

In the following sections, we dive a little bit deeper into each of those components...

The X Window System

On a Unix/Linux system, the X server is a tool which manages the graphical card on your system and offers services to draw things on your screen. These services are defined in the X11 protocol, an industry open standard. Because the interface is open, many X servers exist, one more powerful than the other. Popular X servers are Xorg and XFree86. However, on Gentoo Linux, Xorg is the only available X server (due to legal restrictions as well as support base).

Installing Xorg

To install Xorg on Gentoo Linux, I suggest to read the X Server Configuration HOWTO from Gentoo's documentation repository. It describes how to install Xorg, configure it to work with your hardware and more. This chapter only gives a quick introduction to this.

You should understand that the Xorg configuration defines, amongst other things,

  • the resolution and refresh rates of your screen(s)

  • the language used by your input (keyboard)

  • the drivers used to render stuff (i810, vesa, but also closed, proprietary drivers like nVidia and ATIs)

  • ...

Once configured to your likings, do not forget to take a backup of your configuration (hint: some people place their X configuration online for others to see - there is nothing personal inside anyway).

Installing Xorg

Before installing Xorg, first make sure that the VIDEO_CARDS and INPUT_DEVICES variables are set in /etc/portage/make.conf:

INPUT_DEVICES="evdev keyboard mouse"
VIDEO_CARDS="vesa intel"

In the above example, I selected the vesa video driver (a default driver that is supported by most video cards, but with little functionality) and intel video driver (as I have an Intel graphic card).

Next, install x11-base/xorg-server:

# emerge x11-base/xorg-server

Once finished, it is time to check out the graphical server environment.

Testing Xorg

Try out Xorg without using any configuration file. The Xorg server will try to automatically detect the necessary settings and, to be honest, does a fine job at that. Don't test out things as root though!

$ startx

If you haven't configured a graphical environment yet, you'll be greeted with a console and an ugly background. However, that alone should suffice to verify if your mouse and keyboard are working as well as do a preliminary verification of the resolution of your screen.

If the graphical server doesn't seem to function properly, make sure to read up on Gentoo's Xorg Server Configuration HOWTO.

Window Managers

Window managers interact with the X server using the X11 interface and manage how your graphical environment looks like, but also how it behaves (for instance, there are window managers that do not support dragging windows).

Certain window managers are accompanied by various other tools that integrate nicely with the window manager. These tools offer services like a panel (from which you can launch commands or programs immediately), application menus, file manager etc. The aggregation of these tools is often called a desktop environment because it offers a complete desktop to the user.

Installing a Window Manager

Gentoo supports many window managers. To install one, simply emerge it.

For fluxbox, a popular, lightweight window manager, Gentoo even has official documentation available: the Fluxbox article.

Activating a Window Manager

To activate a window manager for your end user, create a file called .xinitrc in your home directory. Inside it, you just add "exec <manager>" where <manager> is the command to launch the window manager.

For instance, for fluxbox:

exec fluxbox

Desktop Environments

The majority of Linux users use a desktop environment to work with their work station. The two most used desktop environments are KDE and GNOME. The third environment, XFCE4, is gaining momentum as a lightweight yet powerful desktop environment.

GNOME

The GNOME desktop environment is the default desktop environment for many Linux distributions such as Fedora and RHEL. Its desktop is very simple to use: the number of visible options is kept low to not confuse users, and all applications that want to integrate with the GNOME desktop should adhere to various guidelines such as the user interface guideline.

Gentoo has a GNOME Configuration HOWTO available as well.

KDE

The KDE desktop is a fully featured desktop environment which offers all the functionality a regular user might expect from his system. KDE comes with many tools, ranging from network related tools (browsers, IM, P2P) to office tools, multimedia tools, authoring and even development environments.

Gentoo provides a KDE article.

XFCE4

The XFCE4 desktop is designed to still run smoothly on low memory systems (32 Mbytes and more). Often, power users use XFCE4 even on large memory systems just to reduce the memory overhead of the graphical environment.

Gentoo provides an XFCE Configuration Howto.

Activating a Desktop Environment

To activate a desktop environment for your end user, create a file called .xinitrc in your home directory. Inside it, you just add "exec <environment>" where <environment> is the command to launch the desktop environment.

For instance, for Xfce4:

exec xfce4-session

Logging on Graphically

If you want to log on to your system using a graphical logon manager, you need to do two things:

  • Install a graphical logon manager

  • Setup the default graphical environment

Install Graphical Logon Manager

The desktop environments KDE and GNOME provide their own graphical logon manager (which are called kdm and gdm respectively). If you don't have them or want to use a different one, I recommend x11-misc/slim. It is a lightweight graphical logon manager.

# emerge x11-misc/slim

Once a graphical logon manager is available, configure the xdm service to use it.

In /etc/conf.d/xdm:

DISPLAYMANAGER="slim"

Finally, add the xdm service to the default runlevel.

# rc-update add xdm default

Setup the Default Graphical Environment

To setup the default graphical environment for a user, you need to create your .xinitrc file as mentioned before (Activating a Window Manager or Desktop Environment).

Supporting 3D Acceleration

The graphical environment can also use 3D acceleration.

Now, 3D acceleration is a tricky subject because there are many implementations that offer 3D services. For instance, you can have 3D services with software rendering (i.e. no delegation of rendering to specific 3D hardware) but this usually isn't seen as 3D acceleration.

When you have a graphic card capable of rendering 3D, you will need to configure the X Window System to hand over 3D rendering tasks to the graphic card. This can happen through either open standards or specifications (such as OpenGL) or through closed, proprietary drivers (such as the nVidia drivers).