[an error occurred while processing this directive]
[an error occurred while processing this directive] Using the X Window SystemThe X Window System forms the foundation for KDE, GNOME, and a variety of window managers that can be used in Linux and other UNIX systems. Red Hat has integrated window manager and desktop features so tightly together in Red Hat Linux that separating the components to, for example, pop in a different window manager or modify menus is difficult. Despite the fact that so much is piled on X to form KDE and GNOME desktop environments, you can completely bypass those environments and choose your own look and feel. You can do this by starting X, your window manager of choice, and selected applications yourself. The following sections describe how to use the X Window System directly to create your own sort of desktop environment. Starting the GUI yourselfYou can override the default behavior of the startx command (which usually launches KDE or GNOME, as you choose) by creating a $HOME/.xinitrc file and changing your system to boot to init level 3. The .xinitrc file can start up some client processes and run the window manager you choose. Here is an example of the contents of a $HOME/.xinitrc file:
In this example, the .xinitrc file tells startx to run the xeyes and xterm clients. Finally, the file starts up the twm window manager. After you exit your window manager, the X server is halted. You are then returned to your login shell. You can use applications or window managers other than those shown. Understanding the X Window SystemRegardless of which desktop environment or window manager you use, the common underlying software is the X Window System. Although you can quite happily use your desktop without ever directly accessing X, getting to know some of the features of X can help you to better understand how all GUI interfaces in Linux work. You can change X resources that apply to your desktop in general, as well as specific X clients that you run. Most X clients use standard options to set background and foreground colors, window titles, and placement on-screen. This section describes how to set X resources that apply to the general desktop, as well as to X client programs. The most common ways to set X resources are by using the following:
You can also run commands to change attributes related to general desktop, such as your keyboard mappings (xmodmap command). The following sections describe how to change X resources by using both X client command-line options and X resource files. X client command-line optionsIf you run X client commands or put them in a configuration file to start automatically, you can add options that affect how the client looks and behaves. These options are part of the X toolkit, so they are available regardless of what window manager you are using. Table 1 describes options that can be used with many different X client commands.
In most cases, you can use several of these X options on the same command line. The following sections provide examples of X command options that are used with some common X clients.
Example oneThe xeyes command opens a small window that contains a pair of eyes. Those eyes follow your mouse movements around the screen. Here is an example of the xeyes command with several options:
This runs the xeyes command with the pupils (-fg) set to red and the whites of the eyes (-center) set to yellow. The -center option is specific to xeyes. The ampersand (&) runs the command in the background. Example twoThe xlogo command simply displays an X (representing the X Window System) on your display. Here is an example of the xlogo command with several options:
This places an X logo in the lower right-hand corner of the screen (-0-0) at a size of 300 x 300 pixels. The background behind the X is green (-bg), whereas the X itself is red (-fg). If the location had been set to +0+0, the X would have been placed in the upper left-hand corner. The ampersand (&) runs the command in the background.
Example threeThe xterm command starts a Terminal window on your desktop. Here is an example of an xterm command with several options:
This command opens an xterm window and tries to log in to a remote computer called comp1 (-e ssh comp1). The words Login to Comp1 appear in the xterm window’s title bar. To try this on your own computer, substitute comp1 with the name of a computer on your network. This example represents a great way to start an application and identify the activity of that application in the title bar of the xterm window. (This is a particularly good technique if an xterm command is used to log in to another computer. The title reminds you that you are not working on your own computer within that window, because you’re logged in remotely.)Example fourX resources can also be set on a command line. The following is an example of an -xrm option being used to set resources for an xterm window:
This command opens an xterm window with the color of the cursor set to blue. You can set any xterm resource using the -xrm option. Try a few others, such as -xrm XTerm*background:Red or -xrm XTerm*foreground:Yellow. You can have more than one resource set at a time, but each must be preceded with -xrm.
X resource filesWhenever you specify a resource for an X client, that resource follows a fairly simple form. It consists of class name, attribute, and a value. The class name is just the name of the application with the first letter capitalized. Some class names that begin with the letter x, however, capitalize the second letter as well (for example, the class name for xterm is XTerm). The attribute identifies the element in that application. The value is what that element is set to. Here is an example of an X resource:
The object of this attribute is the xterm command. The attribute is the background. The value sets the background to red. X resources that are specific to a particular client are organized in a hierarchy, in what is called a widget class. To find this hierarchy for an X client, check its man page and look for a WIDGETS heading. (Not all man pages have this heading.)
Because the hierarchy of resources can allow long names, you can use an asterisk in a resource name for what is called a loose binding. This means that any number of characters can be matched by the asterisk (as an asterisk is used as a wildcard in the shell). So, in the example, any resource that ends with the attribute background for the XTerm class is Red. If you want to be more specific in how you match a resource name, use a period (.) to create a tight binding in a resource name. A tight binding enables you to be more specific about the resource you want. If you want all backgrounds in the xterm window to be Black and foregrounds to be White, for example, but you want the scrollbar background to be Red and the foreground to be Yellow, use the following resources:
Most X apps accept these attributes: background, foreground, borderwidth, and bordercolor. Many also accept title (to change the name in the title bar), geometry (to set window size and location), and font (to change the font used in the window). Remember that you can add resources in several ways: .Xdefaults, .Xresources, application-specific resource files in your home directory (such as XTerm), or by using the -xrm “resource” option on an X client’s command line. Here are a few X resource examples to get a feel for:
In these examples, the first line shows buttons on the xfontsel window in red. The second line places the xclock utility in the lower-left corner of the screen. The third line sets the fonts used in an xterm window to be the 9x15bold font. X colorsWhenever you define X resources, you have several ways to refer to colors. One way that is easy to understand is to use common names: red, blue, and so on. However, you can also use hexadecimal notation or specific numeric red, green, and blue values to refer to more subtle colors. The table of colors that are supported by X are contained in /usr/lib/X11/rgb.txt file. Each entry in this file consists of three numbers and a name. The three numbers represent the intensity of red, green, and blue, respectively. A zero (0) represents no trace of the color, whereas 255 represents full intensity. Here are some examples of colors in this file:
You can use any of these names as arguments to color resource options. (Remember to put multiword colors in quotes.) Another way to refer to a color is with hexadecimal notation. In this form, there are six integers, each representing a number from 0 to 16. The first two integers refer to red, the next two refer to blue, and the final two refer to green. So, in the first two integers, ff is 255 (all red) and 00 is zero (no red). The same is true for setting the amounts of blue and green used. Here are some common colors in hexadecimal notation:
Depending on where you enter colors in hexadecimal notation, you may need to put the numbers in quotes. To set the background color to green for an xterm window, for example, you would type xterm -bg “#00ff00” at the command line. X fontsTo see the fonts that are available to X on your computer, use the xlsfonts command. The xlsfonts command just dumps a listing of fonts to your screen. So to view the contents, you should either pipe the output to the more command or direct the output to a file. Here are two ways to run the command:
Use the command xterm -fn “font” to try some of these fonts:
The X server maintains a list of font locations in what is called the font path. Whenever you display a list of fonts or choose particular fonts to assign as resources, the font path is checked to determine whether the font exists. Font path is similar to the shell PATH, which searches for commands by checking a list of directories, using the order in which they appear in the PATH. Similarly, X checks for a font by using the order set by font path. To see the current font path, type xset -q| grep -i font. Changing X display resourcesResources associated with your X server display affect the behavior of the mouse and keyboard and can modify such things as the sounds and background of your desktop. There are several commands to change and view the resources that are set for your display:
Typically, you would try different values with these commands to find
settings that look and behave the way that you want. Then you could add
these commands, with options, to your .xinitrc
or .xsession files so that
they are in effect each time you start the desktop. You can change several attributes of your mouse, cursor, and keyboard mappings. You can speed your mouse motion. You can change what each mouse button does. You can assign a different cursor to the mouse pointer. You can modify annoying sounds. You can set the background of your display. You can set the idle time of your screen saver. Mouse speedTo change the speed that your mouse cursor travels in proportion to how far you move the mouse, change the acceleration value by using the xset command. To set the m option to xset, enter a number to represent acceleration. You can also add a number, following the first one that represents a threshold. The movement of the cursor is the first number (acceleration) times the movement of the mouse (the distance the mouse is moved) after it passes the set threshold of pixels. (The reason for waiting for the threshold to be reached is so that you can move the cursor in a refined way for short distances.) Here is an example:
This example sets the mouse to move five times as fast as it would normally move for the amount that you move the mouse. Acceleration begins after the mouse moves 10 pixels. If you try this option, you see that the mouse cursor starts out moving slowly for a short distance and then begins moving quickly. Mouse buttonsIf you are left-handed, you can use the xmodmap command to change the arrangement of the mouse buttons. To have the mouse button that you most often use to select items under your index finger, reverse the order of the three mouse buttons. First, use the following command to check the current arrangement of your mouse buttons:
This output shows that the five mouse buttons are assigned in order. The code for the first button is assigned to button one and so on. To change the order (for a left-handed person), type the following:
Mouse cursorBy default, the cursor representing the location of the mouse pointer whenever it is over the root window is an X. If you like, you can change the cursor to a different representation by using the xsetroot command. The full list of cursors is available in the X Windows include file (/usr/X11R6/include/X11/cursorfont.h). Here is an example of how you can change the mouse cursor to a different icon:
This example changes the X cursor to a box with a small mosaic pattern in it. You can also change the cursor to any of the following values:
You can modify the annoying sounds that your computer makes by using the xset command. You can turn off the beep your computer makes if you make a mistake by typing the following:
You can turn the beep back on as follows:
You can change how loud your computer beeps by using a numeric value after the b option. The number represents a percentage of the maximum loudness (from 1 to 100). The following, for example, sets the bell to 90 percent of its maximum loudness:
X-application resourcesMost X applications support some of, or all, the standard X options (geometry, foreground, background, and so on), as well as some options that are specific to the application. Many of them start with a set of default options defined. You can override these default options in several different ways. You have separate resource files for each X application (that chooses to create one) in the /usr/lib/X11/app-defaults directory. Each file is named after the X client that it represents, with the exception that the first one or two characters are capitalized. Although I do not recommend it, you could edit these files and change the resources. That way, everyone who starts X on your system starts with the same set of resources set for the applications. The preferred way to change resources for your X clients is to copy the resource file that you want to change to your home directory. Then make changes and additions to it. After you start the X client that is associated with that file, the resources are incorporated into the client. Even if no default resource file exists for an X client, you can create one. For example, I created a $HOME/XEyes file and added the following lines to it:
After I ran the xeyes command, the title My Eyes appeared on the taskbar for the application. The eyeballs were colored yellow and the pupils were red. Instead of using individual files, you can add X resources associated with any client into your .Xresources or .Xdefaults file. If you make a change to those files, you can immediately merge those changes into the current desktop as follows:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|