Next Previous Contents

4. Working In X

In this section we will become familiar with running clients in X Window and the basic procedures involved in using the system. X is not an intuitive interface on its own, and without any window manager, it is easiest to use as a display for programs started from the command line. One of the most common uses for X is just to have several xterm windows open at the same time. Not exactly maxing out the graphics capabilities of the computer, but it's a nice feature to start with.

The flexibility and usefulness of the command line is so great, in fact, that you don't really need a window manager. It's nice, and you will want it very quickly, but the fact is that you can get by without one, just the command line and the mouse. If you give it a shot, you'll be surprised as to the exact distinctions between the clients and the window manager. If you start toying around with this, however, remember that the key combination Ctrl-Alt-Backspace gets you out of X Window in a pinch.

4.1 Command Line Options

Most X programs try to use the same basic names for command line options. All applications written using the MIT X Toolkit Intrinsics automatically accept the following options:

-display display

This option specifies the X server to use. See the section on Display Names for details.

-geometry geometry

The initial size and location of the window, in a format such as widthxheight+hoffset+voffset or +hoffset-voffset. Note that if you put in a negative horizontal or vertical offset, the window will be placed counting backward from the right or the bottom of the screen, respectively.

-font font

The font to use for displaying the text in your window.

-bg color

The color to use for the window background.

-fg color

The color to use for the window foreground.

-name resource-name

Useful for specifying the name under which the resources for this application will be found. This is useful to distinguish between invocations of the same application, for example, two xterms can be named differently so that they may inherit different resources based upon those names in the resource database.

-title string

This is the title to be used for the window on your display, generally used by the window manager to put a descriptive title at the top of the window. Not to be confused with the -name option.

-iconic

Invoke window as an icon.

-xrm resource-string

This option specifies a resource name and value to override any defaults that may already be set. Also useful for setting X resources that do not have explicit command line options. For instance, the command line xterm -xrm "xterm*background: blue" is functionally identical to typing xterm -bg blue.

4.2 Display Names

Every X Server has a display name of the form:

hostname:displaynumber.screennumber

The hostname specifies the name of the machine to which the display is actually, physically connected. The hostname can be omitted, and if so, the server on the same machine will be chosen. In fact, if you are the only one using X on your computer, you will want to just leave this off of your display specifications. The displaynumber should probably be zero, this is used if the X Server is controlling more than one keyboard and monitor unit, for instance, a network of X terminals. The screennumber specifies which monitor in a multiple monitor setup should be used. Following this specification, you would open an xterm window on your local machine with the option -display :0.0. You can see that we have omitted the hostname from the option, so the current machine is assumed.

On Linux systems, your DISPLAY variable holds your display name, which on my system is :0.0. This is usually set by xterm, or one of the scripts that starts X Window for you, although you can set it yourself, or as discussed above, use the -display command line option when invoking your application.

If you have opened an xterm or rxvt window, and then opted to do super-user work via the su command, you will find that if you try to launch an X application you will have no display to launch it on. Silly it seems, because you are sitting right in front of your display, but the trick to getting this to work is to pass an option on the command line to the program such as -display :0.0, and it will work fine.

4.3 XTerm Versus Rxvt, or, Know Thy Terminal Emulator

Your choice of terminal emulator can affect your experience in X almost as much as your window manager, so a little discussion of your best options is due here. A terminal emulator is a program such as xterm, discussed above, which lets you emulate the simple console of Linux in X. You will rely heavily on the program you choose, so it pays to choose it wisely to begin with.

If you have a slow video card, the first thing you should consider doing is switching to rxvt. Using xterm is a good starting point, mainly because it comes standard with all X distributions, but it's not always the best choice. It contains a lot of legacy code, and is quite bloated for a simple terminal emulator. This is partly due to the fact that it's not just a plain text terminal emulator, but also emulates graphics modes that you simply will never use. Because of this, you may wish to switch to rxvt, and also because xterm can be extremely slow. I'm not sure why it's so slow, but if you have a slow video card you'll know what I mean, and you'll be amazed at the difference when you dump xterm.

Some other perks of rxvt include pixmap backgrounds, and a much nicer scrollbar. If you specify the -pixmap option on the command line (and have support compiled in to your version!) you will get any .xpm-type picture in the background. A very cool feature, and it surprisingly doesn't slow down your output at all, it still redraws faster than your xterm window. Give it a shot, I haven't seen it around lately but I think it can be found on metalab.


Next Previous Contents