Home > Slackware Linux Essentials > Slackware Linux Essentials - Chapter 6 X Configuration

Slackware Linux Essentials - Chapter 6 X Configuration

January 5th, 2009

Warning: file_get_contents(http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=1TJ8QTQ6ZFCVAJ3X1T02&AssociateTag=ii0c3-20&Operation=ItemSearch&SearchIndex=Books&ResponseGroup=Small,Images&Keywords=backup) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/manusia2/public_html/wp-content/plugins/amazonfeed/php/amazonfeed.class.php on line 271

Starting with Slackware-10.0, the X Window environment in Slackware is provided by Xorg. X is responsible for providing a graphical user interface. It is independent from the operating system, unlike Windows or the MacOS.

The X Window System is implemented through many programs that run in userland. The two main components are the server and the window manager. The server provides the lowlevel functions for interacting with your video hardware, thus it is system specific. The window manager sits on top of the server and provides the user interface. The advantage to this is you can have many different graphical interfaces by simply changing the window manager you use.

Configuring X can be a complex task. The reason for this is the vast numbers of video cards available for the PC architecture, most of which use different programming interfaces. Luckily, most cards today support basic video standards known as VESA, and if your card is among them you’ll be able to start X using the startx command right out of the box.

If this doesn’t work with your card, or if you’d like to take advantage of the high-performance features of your video card such as hardware acceleration or 3-D hardware rendering, then you’ll need to reconfigure X.

To configure X, you’ll need to make an /etc/X11/xorg.conf file. This file contains lots of details about your video hardware, mouse, and monitor. It’s a very complex configuration file, but fortunately there are several programs to help create one for you. We’ll mention a few of them here.


6.1 xorgconfig

This is a simple menu driven frontend that’s similar in feel to the Slackware installer. It simply tells the X server to take a look at the card, and then set up the best initial configuration file it can make based on the information it gathers. The generated /etc/X11/xorg.conf file should be a good starting point for most systems (and should work without modification).

This is a text-based X configuration program that’s designed for the advanced system administrator. Here’s a sample walkthrough using xorgconfig. First, start the program:

# xorgconfig

This will present a screenful of information about xorgconfig. To continue, press ENTER. xorgconfig will ask you to verify you have set your PATH correctly. It should be fine, so go ahead and hit ENTER.

Figure 6-1. xorgconfig Mouse Configuration

Select your mouse from the menu presented. If you don’t see your serial mouse listed, pick the Microsoft protocol — it’s the most common and will probably work. Next xorgconfig will ask you about using ChordMiddle and Emulate3Buttons. You’ll see these options described in detail on the screen. Use them if the middle button on your mouse doesn’t work under X, or if your mouse only has two buttons (Emulate3Buttons lets you simulate the middle button by pressing both buttons simultaneously). Then, enter the name of your mouse device. The default choice, /dev/mouse, should work since the link was configured during Slackware setup. If you’re running GPM (the Linux mouse server) in repeater mode, you can set your mouse type to /dev/gpmdata to have X get information about the mouse through gpm. In some cases (with busmice especially) this can work better, but most users shouldn’t do this.

xorgconfig will ask you about enabling special key bindings. If you need this say “y”. Most users can say “n” — enter this if you’re not sure.

Figure 6-2. xorgconfig Horizontal Sync

In the next section you enter the sync range for your monitor. To start configuring your monitor, press ENTER. You will see a list of monitor types — choose one of them. Be careful not to exceed the specifications of your monitor. Doing so could damage your hardware.

Figure 6-3. xorgconfig Vertical Sync

Specify the vertical sync range for your monitor (you should find this in the manual for the monitor). xorgconfig will ask you to enter strings to identify the monitor type in the xorg.conf file. Enter anything you like on these 3 lines (including nothing at all).

Figure 6-4. xorgconfig Video Card

Now you have the opportunity to look at the database of video card types. You’ll want to do this, so say “y”, and select a card from the list shown. If you don’t see your exact card, try selecting one that uses the same chipset and it will probably work fine.

Next, tell xorgconfig how much RAM you have on your video card. xorgconfig will want you to enter some more descriptive text about your video card. If you like, you can enter descriptions on these three lines.

You’ll then be asked which display resolutions you want to use. Again, going with the provided defaults should be fine to start with. Later on, you can edit the /etc/X11/xorg.conf file and rearrange the modes so 1024×768 (or whatever mode you like) is the default.

At this point, the xorgconfig program will ask if you’d like to save the current configuration file. Answer yes, and the X configuration file is saved, completing the setup process. You can start X now with the startx command.


6.2 xorgsetup

The second way to configure X is to use xorgsetup, an automagical configuration program that comes with Slackware.

To run xorgsetup, log in as root and type:

# xorgsetup

If you’ve already got an /etc/X11/xorg.conf file (because you’ve already configured X), you’ll be asked if you want to backup the existing config file before continuing. The original file will be renamed to /etc/X11/xorg.conf.backup.


6.3 xinitrc

xinit(1) is the program that actually starts X; it is called by startx(1), so you may not have noticed it (and probably don’t really need to). Its configuration file, however, determines which programs (including and especially the window manager) are run when X starts up. xinit first checks your home directory for a .xinitrc file. If the file is found, it gets run; otherwise, /var/X11R6/lib/xinit/xinitrc (the systemwide default) is used. Here’s a simple xinitrc file:

#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# start some nice programs

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

All of those “if” blocks are there to merge in various configuration settings from other files. The interesting part of the file is toward the end, where various programs are run. This X session will begin with the twm(1) window manager, a clock, and three terminals. Note the exec before the last xterm. What that does is replace the currently running shell (the one that’s executing this xinitrc script) with that xterm(1) command. When the user quits that xterm, the X session will end.

To customize your X startup, copy the default /var/X11R6/lib/xinit/xinitrc to ~/.xinitrc and edit it, replacing those program lines with whatever you like. The end of mine is simply:

# Start the window manager:
exec startkde

Note that there are several xinitrc.* files in /var/X11R6/lib/xinit that correspond to various window managers and GUIs. You can use any of those, if you like.


6.4 xwmconfig

For years, Unix was used almost exclusively as the operating system for servers, with the exception of high-powered professional workstations. Only the technically inclined were likely to use a Unix-like operating system, and the user interface reflected this fact. GUIs tended to be fairly bare-bones, designed to run a few necessarily graphical applications like CAD programs and image renderers. Most file and system management was conducted at the command line. Various vendors (Sun Microsystems, Silicon Graphics, etc) were selling workstations with an attempt to provide a cohesive “look and feel”, but the wide variety of GUI toolkits in use by developers led inevitably to the dissolution of the desktop’s uniformity. A scrollbar might not look the same in two different applications. Menus might appear in different places. Programs would have different buttons and checkboxes. Colors ranged widely, and were generally hard-coded in each toolkit. As long as the users were primarily technical professionals, none of this mattered much.

With the advent of free Unix-like operating systems and the growing number and variety of graphical applications, X has recently gained a wide desktop user base. Most users, of course, are accustomed to the consistent look and feel provided by Microsoft’s Windows or Apple’s MacOS; the lack of such consistency in X-based applications became a barrier to its wider acceptance. In response, two open source projects have been undertaken: The K Desktop Environment, or KDE, and the GNU Network Object Model Environment, known as GNOME. Each has a wide variety of applications, from taskbars and file managers to games and office suites, written with the same GUI toolkit and tightly integrated to provide a uniform, consistent desktop.

The differences in KDE and GNOME are generally fairly subtle. They each look different from the other, because each uses a different GUI toolkit. KDE is based on the Qt library from Troll Tech AS, while GNOME uses GTK, a toolkit originally developed for The GNU Image Manipulation Program (or The GIMP, for short). As separate projects, KDE and GNOME each have their own designers and programmers, with different development styles and philosophies. The result in each case, however, has been fundamentally the same: a consistent, tightly integrated desktop environment and application collection. The functionality, usability, and sheer prettiness of both KDE and GNOME rival anything available on other operating systems.

The best part, though, is that these advanced desktops are free. This means you can have either or both (yes, at the same time). The choice is yours.

In addition to the GNOME and KDE desktops, Slackware includes a large collection of window managers. Some are designed to emulate other operating systems, some for customization, others for speed. There’s quite a variety. Of course you can install as many as you want, play with them all, and decide which you like the most.

To make desktop selection easy, Slackware also includes a program called xwmconfig that can be used to select a desktop or window manager. It is run like so:

% xwmconfig

Figure 6-5. Desktop Configuration with xorgconfig

You’ll be given a list of all the desktops and window managers installed. Just select the one you want from the list. Each user on your system will need to run this program, since different users can use different desktops, and not everyone will want the default one you selected at installation.

Then just start up X, and you’re good to go.


6.5 xdm

As Linux becomes more and more useful as a desktop operating system, many users find it desirable for the machine to boot straight into a graphical environment. For this, you will need to tell Slackware to boot straight into X, and assign a graphical login manager. Slackware ships with three graphical login tools, xdm(1), kdm, and gdm(1).

xdm is the graphical login manager shipped with the X.org system. It’s ubiquitous, but not as fully features as alternatives. kdm is the graphical login manager shipped with KDE, The K Desktop Environment. Finally, gdm is the login manager shipped with GNOME. Any of the choices will allow you to log in as any user, and choose what desktop you wish to use.

Unfortunately, Slackware doesn’t include a nice program like xwmconfig for choosing what login manager to use, so if all three are installed you may have to do some editing to choose your preference. But first, we’ll discuss how to boot into a graphical environment.

In order to start X at boot, you need to boot into run-level 4. Run-levels are just a way of telling init(8) to do something different when it starts the OS. We do this by editing the config file for init, /etc/inittab.

# These are the default runlevels in Slackware:
#   0 = halt
#   1 = single user mode
#   2 = unused (but configured the same as runlevel 3)
#   3 = multiuser mode (default Slackware runlevel)
#   4 = X11 with KDM/GDM/XDM (session managers)
#   5 = unused (but configured the same as runlevel 3)
#   6 = reboot

# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:

In order to make Slackware boot to a graphical environment, we just change the 3 to a 4.

  # Default runlevel. (Do not set to 0 or 6)
  id:4:initdefault:

Now Slackware will boot into runlevel 4 and execute /etc/rc.d/rc.4. This file starts up X and calls whatever login manager you’ve chosen. So, how do we choose login managers? There are a few ways to do this, and I’ll explain them after we look at rc.4.

  # Try to use GNOME's gdm session manager:
  if [ -x /usr/bin/gdm ]; then
    exec /usr/bin/gdm -nodaemon
  fi

  # Not there?  OK, try to use KDE's kdm session manager:
  if [ -x /opt/kde/bin/kdm ]; then
    exec /opt/kde/bin/kdm -nodaemon
  fi

  # If all you have is XDM, I guess it will have to do:
  if [ -x /usr/X11R6/bin/xdm ]; then
    exec /usr/X11R6/bin/xdm -nodaemon
  fi

As you can see here, rc.4 first checks to see if gdm is executable, and if so runs it. Second on the list is kdm, and finally xdm. One way of choosing a login manager is to simply remove the ones you don’t wish to use using removepkg. You can find out more about removepkg in Chapter 18.

Optionally, you can remove the executable permission from those files that you don’t want to use. We discuss chmod in Chapter 9.

# chmod -x /usr/bin/gdm

Finally, you can just comment out the lines for the login manager you don’t want to use.

  # Try to use GNOME's gdm session manager:
  # if [ -x /usr/bin/gdm ]; then
  #   exec /usr/bin/gdm -nodaemon
  # fi

  # Not there?  OK, try to use KDE's kdm session manager:
  if [ -x /opt/kde/bin/kdm ]; then
    exec /opt/kde/bin/kdm -nodaemon
  fi

  # If all you have is XDM, I guess it will have to do:
  if [ -x /usr/X11R6/bin/xdm ]; then
    exec /usr/X11R6/bin/xdm -nodaemon
  fi

Any lines preceded by the hash mark (#) are considered comments and the shell silently passes them. Thus, even if gdm is installed and executable, the shell (in this case bash) won’t bother checking for it.

Tags: backup, database, file manager, manage, slackware, Slackware Linux Essentials

Related posts

Slackware Linux Essentials , , , ,

  1. No comments yet.
  1. No trackbacks yet.