Task 2.10: Use X for Day-to-Day Operations
X, like many Linux tools, is highly modular. The X server itself provides networking features but only fairly minimal graphics features: the ability to create windows, draw simple shapes, display text, and so on. X does not, by itself, provide the ability to display dialog boxes, tools for moving or resizing windows via the mouse, program menu bars, and so on. These features are all provided by add-on tools. Some of these tools, known as widget sets, are chosen by programmers; you as a user or system administrator have no choice over what widget sets your programs use. Other add-on tools, though, can be chosen by users and system administrators. Window managers provide decorative borders around windows and enable users to move and resize windows. They also often provide a few additional features, such as tools for launching programs and the ability to maintain multiple desktops, each with its own set of programs running. Desktop environments go further; they provide a collection of useful utilities, including calculators, file browsers, tools to set X options, and so on. Desktop environments are usually built atop particular window managers, but most window managers are independent of desktop environment projects. Some advanced Linux users run "bare" window managers to avoid expending system resources on running a full desktop environment, but novices and other advanced users often prefer to run a complete desktop environment.
The K Desktop Environment (KDE; http://www.kde.org) and the GNU Network Object Model Environment (GNOME; http://www.gnome.org) are the two most popular desktop environments for Linux. Both attempt to provide a wide range of tools but in the process end up consuming vast amounts of memory. A few others, such as XFce (http://www.xfce.org) and XPde (http://www.xpde.com), focus on other goals, such as slimmer resource requirements or a "look and feel" that mimics that of Windows XP, respectively. You can consult http://xwinman.org for information on these and other window managers and desktop environments.
Knowing how to install and select a window manager or desktop environment will enable you to get the most out of your system—you can pick a slim window manager alone if your system is short on memory or a big desktop environment if you've got lots of RAM and want all the creature comforts. As a system administrator, you can choose which options to make available. As a user, you can select which option to use as a personal default or on a per-session basis.
The gandalf computer, which you've just configured for remote access in the previous task, has a dozen users, and they have different preferences concerning their desktop environments. To satisfy these users, you must make several environments available as login options:
. KDE . GNOME . XFce IceWM (http://www.icewm.org) FVWM (http://www.fvwm.org)
The first three of these environments are full desktop environments, but the last two are window managers alone. You must configure gandalf to enable users to select any of these environments at login time.
Scope of Task
To complete this task, you must modify your system to present certain login-time options. This entails installing software and modifying your KDM or GDM configuration to present the relevant options to users. XDM provides relatively limited login environment selection options— specifically, XDM runs the .xsession script in the user's home directory. This script can launch any window manager or desktop environment that the user desires, but the user cannot select an environment on-the-fly at the moment of login. Thus, I don't describe XDM configuration in detail for this task.
This task should take half an hour to an hour to complete. Once you're familiar with the procedure, you should be able to add desktop environments to a system in a few minutes, assuming you don't run into problems installing the software.
Begin by logging into the computer and acquiring rootprivileges. Although the scenario specifies that the computer is configured for remote access, that's not necessary to complete this task—the configuration changes required are identical whether or not the XDMCP server is actually configured for remote access. Because your changes will require restarting your XDMCP server, and therefore terminating any X session, you should work from a text-mode login or at least be prepared to have your X session shut down when you implement the changes. If the computer doesn't display an XDMCP GUI login prompt when it boots, configure it to do so, or at least so that such a server is installed and can be run.
As usual, working as root poses the risk of accidentally causing problems on your system. Mistakes in the configurations you implement could conceivably cause X to fail to start, although it's more likely that you simply won't see the options you'd intended to add or that you won't be able to launch those environments.
To add new environments to the options available at login time, you must both install software and configure your XDMCP server. KDM and GDM are configured in similar ways, so you'll follow just one procedure no matter which environment you're using. Once you've made your changes, you should check that you can log in and launch your chosen desktop environment or window manager.
Installing New Environments
In order to use a window manager or desktop environment, you must install it on your computer. Unfortunately, this task is complex enough that I can't fully describe it here. If you need help, consult Phase 3, "Managing Software."
Fortunately, most Linux distributions install a variety of window managers and desktop environments as default options. Chances are you've got KDE or GNOME (and quite possibly both of them) installed already, along with at least one or two bare window managers. FVWM is often installed by default, and IceWM may be as well. To check for these window managers and desktop environments, look for the following program files: startkde (KDE), gnome-session (GNOME), startxfce4 or xfce4-session (XFce), icewm or icewm-session (IceWM), and fvwm (FVWM).
If a window manager or desktop environment isn't installed, you can install it using your distribution's package system or from the source code provided by the package's developers, as described in Phase 3. Alternatively, you can ignore it or substitute another window manager that is installed in your system.
Configuring KDM and GDM
Modern versions of both KDM and GDM rely on files stored in /usr/share/xsessions to determine what options to present for possible login sessions. This directory holds files with names of the form environment.desktop, where environmentis the environment name (such as KDE or GNOME). The precise names vary from one distribution to another, but you should be able to spot the session file for your environment of choice—if it exists. For this task, look for kde.desktop, gnome.desktop, xfce.desktop, icewm.desktop, and fvwm.desktop or similar files. (Some distributions capitalize parts of certain environment names, and there may be other variations of some of these names.)
If a session file doesn't exist for your environment, you can create one. The simplest way to do this is probably to copy an existing file and make appropriate changes. Listing 2.2 shows a sample file that launches IceWM. You should change the Nameand Commententries if you create a file for another environment. These fields present a name and a comment, both of which are visible to users. Just as important, you should change the Exec and TryExeclines, which point to the program that's used to launch the environment. KDE uses startkde, GNOME uses gnome-session, XFce uses startxfce4or xfce4-session, and most bare window managers, including fvwm, use their own names. (Listing 2.2's IceWM window manager is an exception; it uses icewm-session, although icewm also works with some IceWM packages.)
Listing 2.2: Sample X Session File for GDM and KDM
[Desktop Entry] Encoding=UTF-8 Name=IceWM Comment=This session logs you into IceWM Exec=icewm-session TryExec=icewm-session # no icon yet, only the top three are currently used Icon= Type=Application
Most distributions provide a large number of session files for a wide variety of window managers and desktop environments. Sometimes these come with the GDM and KDM programs; they're likely to be buried in an obscure directory such as /usr/share/apps/kdm/ sessions/ or /usr/kde/3.5/share/apps/kdm/sessions/. Sometimes window manager or desktop environment packages ship with a suitable session file; these files may be buried in obscure locations or may be automatically installed in /usr/share/xsessions. In the latter case, you need do nothing special, since the act of installing the environment automatically adds it to your GDM and KDM menus.
Testing Your Configuration
Once you've added an X session file, you must restart your XDMCP server, as described earlier in "Identifying Your XDMCP Server" in Task 2.9. When KDM or GDM starts up again, you should see your new session in its list of available sessions, such as the Session Type selector in Figure 2.7, which shows a KDM login prompt. The details of where this selector appears varies from one system to another. In GDM, the relevant option is usually called Session rather than Session Type.
FIGURE 2.7 KDM, like GDM, enables users to select a desktop environment or window manager at login time.
Many distributions remember users' choices for login sessions and use those choices as their defaults or give users the option of changing their defaults when they select a new session. Other distributions, though, including the popular Fedora and Red Hat, require the user to run a special program to make these changes explicit. For Fedora and Red Hat, this program is the Desktop Switching Tool (switchdesk).
Criteria for Completion
To complete this task, you should have successfully added new window managers and desktop environments to your KDM or GDM login prompt. Doing so requires installing the software and creating X session files in the /usr/share/xsessions directory. Some distributions make this task very easy by placing appropriate files in this directory when you install the relevant desktop environment or window manager.
Use the following table of contents to navigate to chapter excerpts, or click here to view Chapter 2 in its entirety.
Managing Linux hardware and the kernel
Part 1: Set BIOS Options for Linux: task 2.1
Part 2: Know the hardware in your computer, task 2.2
Part 3: Resolve hardware conflicts, task. 2.3
Part 4: Configure USB devices to Linux, task. 2.4
Part 5: Configure Linux Disk Drive, task 2.5
Part 6: Configure and compile a kernel for Linux, task 2.6
Part 7: Use Linux power management features, task 2.7
Part 8: Configure X options for Linux, task 2.8
Part 9: Manage X logins for Linux, task 2.9
Part 10: Use X for day-to-day operations, task 10
|ABOUT THE BOOK:|
|Hit the ground running with the street-smart training you'll find in Linux Administrator Street Smarts: A Real World Guide to Linux Certification Skills. Using a "year in the life" approach, it gives you an inside look at Linux administration, with key information organized around the actual day-to-day tasks, scenarios, and challenges you'll face in the field. This valuable training tool is loaded with hands-on, step-by-step exercises covering all phases of Linux administration. Purchase the book from Wiley Publishing|
|ABOUT THE AUTHOR:|
|Roderick W. Smith left a career in academia to pursue his passion for computers. He is particularly interested in Linux and Open Source Software, and has written several books.|
This was first published in February 2007