2.3. Running ProgramsA window manager can open windows of its own. But the main use of a window manager is to manage windows opened by other programs. We mention a few window programs here; Section 2.8, near the end of this chapter, has more. One of the most important X features is that windows can come either from programs running on your local computer, or over a network from programs running on remote computers. The remote computers can run Unix or another operating system. So, if your favorite program from another operating system doesn't run under Unix but has an X interface, you may be able to run that program on its native OS and display its windows with X on your Unix computer. (Check your program's documentation; see Section 8.1 in Chapter 8.) Researchers can run graphical data analysis programs on supercomputers in other parts of the country and see the results in their offices. There's much more than we can explain here. We cover the basics here and in Chapter 6 in Section 6.2, which also has a figure showing how this works. If you'll do a lot of work with X, you may want a detailed reference that explains X and your window manager. 2.3.1. Setting FocusOf all the windows on your screen, only one window receives the keystrokes you type. This window is usually highlighted in some way. For instance, the titlebar of the window that receives your input may be blue instead of the default grey color. In X jargon, choosing the window you type to is called "setting the input focus." Most window managers can be configured to set the focus in one of the following ways:
Your window manager may be configured to give the input focus automatically to any new windows that pop up. 2.3.2. Terminal WindowsOne of the most important windows is a terminal window. A terminal window has a Unix session inside with a shell prompt, just like a miniature alphanumeric terminal. You can have several terminal windows running at the same time, each doing something different. To enter a Unix command or answer a prompt in a window, set the focus there and type. Programs in other windows will keep running; if they need input from you, they'll wait just as they would on a standard terminal. Quite a few programs make terminal windows. One of the best-known programs is xterm. Others include GNOME Terminal and konsole. All perform the same basic job: they allow you to interact with Unix from a shell prompt. Figure 2-2D and Figure 2-4 show a single terminal window with a shell prompt ($). If you enter a Unix command (such as date) at the prompt, it runs just as it would on a terminal that isn't under the X Window System. You can also start other X-based window programs (sometimes called X clients) by entering the program's name at a shell prompt in any terminal window. Although you can start new programs (such as terminal windows, xcalc, and so on) from any open terminal window on your computer, we recommend starting them all from the first terminal window that you open. If you do that, and if your shell has job control (see Chapter 7), it's easy to find and control all the other programs and their windows. Here's an example. To start the calculator called xcalc, enter this command from a terminal window:
$ xcalc & [1] 12345 $ The shell will put the process in the background--so you get another shell prompt right away--and will print a process ID (PID) number, such as 12345. (Chapter 7 has more information on this subject.) If you forget to add the ampersand (&) at the end of the line, then kill (terminate) the xcalc program from the terminal window where you started it by typing your interrupt character (such as CTRL-C). You should get another shell prompt, where you can re-enter the xcalc command correctly. The new window may be placed and get the focus automatically. Or, the window (or an outline of it) may "float" above the screen, following the pointer, until you point somewhere and click the first mouse button to place the window. You can also start a new terminal window from an existing one. Just enter the program's name and an ampersand (for example, xterm &) at the shell prompt. Don't forget the ampersand. The same method will start other X programs. (Later in this chapter, Section 2.8 lists some standard X programs.) 2.3.3. Window Manager MenusYour window manager probably has one or more menus, buttons, and dialogs of its own. These let you control the way the window manager works, overall. They may also launch programs, open the help system, and do other useful things that don't apply to all programs and windows that are currently open (things you can't do with an individual program's own menus, that is). For instance, a window manager menu might let you set how many rows of program launching buttons are in the panel or the color of the frame around each window. Different window managers have different ways to do these things. To find the menus on your window manager, read its documentation or experiment a bit. You might also find that pressing different mouse buttons will open different menus. You may need to hold down the button to keep a menu visible. Move your mouse pointer around to places shown in the following, then try your mouse buttons:
You probably can add commands to some menus, or more icons to a group of program-launching icons. You might add window manager operations or commands to open other windows. For example, a "New Window" menu item can open a new terminal window for you. A "Calculator" item could start xcalc. Different window managers have different ways to do this. Check your documentation. To add a command, you'll need to specify either the program name (such as xterm or mozilla) or the absolute pathname of its executable file (such as /usr/X11R6/bin/xterm). The absolute pathname varies system-to-system; you might find it using the command which or type from a shell prompt, like this: $ type xterm xterm is /usr/X11R6/bin/xterm $ which xterm /usr/X11R6/bin/xterm 2.3.3.1. Exercise: exploring your window system
2.3.3.2. Problem checklist
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|