start page | rating of books | rating of authors | reviews | copyrights

Learning the Unix Operating System

Learning the Unix Operating SystemSearch this book
Previous: 2.2 Starting XChapter 2
Using Window Systems
Next: 2.4 Working with a Mouse
 

2.3 Running Programs

One of the most important X features is that windows can come either from programs running on another computer or from an operating system other than UNIX. So, if your favorite MS-DOS program doesn't run under UNIX but has an X interface, you can run the program under MS-DOS and display its windows with X on your UNIX computer. 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 could cover here. The O'Reilly & Associates book X Window System User's Guide, Volume Three, OSF/Motif Edition has all the details.

2.3.1 Setting Focus

Of all the windows on your screen, only one window receives the keystrokes you type. This window is usually highlighted in some way. By default in the mwm window manager, for instance, the frame of the window that receives your input is a darker shade of grey. 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 two ways:

When you use mwm, any new windows will get the input focus automatically as they pop up.

2.3.2 The xterm Window

One of the most important windows is an xterm window. xterm makes a terminal emulator window with a UNIX login session inside, just like a miniature terminal. You can have several xterm windows at once, 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 separate terminal.

Figure 2.2D and Figure 2.4 show a single xterm window with a shell prompt (%) inside. If you enter a UNIX command (like date), it will run just as it would on a non-window terminal.

You can also start separate X-based window programs (typically called clients) by entering commands in an xterm window. Although you can start new clients (xterm, xcalc, and so on) from any open xterm window on your computer, we recommend starting all of them from the first window that you opened. If you do that, and if your shell has job control (see Chapter 6, Multitasking ), it's easy to find and control all the clients.

Here's an example. To start the calculator called xcalc, enter:

% xcalc &
[1] 12345
%

The shell will print a PID number like 12345. (Chapter 6 has more information on this subject.) If you forget to add the ampersand (&) at the end of the line, kill (terminate) xcalc with your interrupt character (like [CTRL-C] to get another shell prompt - then enter the 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 display, following the pointer - until you point somewhere and click the mouse button to place the window.

You can also start a new xterm from an existing xterm. Just enter xterm & (don't forget the ampersand) at the shell prompt.

The same method works for starting other X programs.

2.3.3 The Root Menu

If you move the pointer onto the root window (the "desktop" behind the windows) and press the correct mouse button (usually the first or third button, depending on your setup), you should see the root menu. You may need to hold down the button to keep the menu visible. The root menu has commands for controlling windows. The menu's commands may differ depending on the system.

Your system administrator (or you, if you study your window manager) can add commands to the root menu. These can be window manager operations or commands to open other windows. For example, a "New Window" menu item can open a new xterm window for you. A "Calculator" item could start xcalc.

2.3.3.1 Exercise

Change to your home directory.

Enter cd

Open two xterm windows.

Enter xterm & twice or select that item twice on the root menu.

Practice setting focus on both new windows and entering UNIX commands in each.

Click on window and/or move pointer there. Enter who am i, etc.

Start the clock from one window.

Enter oclock &

Start the calculator from one window and try it.

Enter xcalc &

Change working directory (see Chapter 3, Your UNIX Account ) in only one window.

Enter cd /bin

Check working directory (see Chapter 3) in both windows.

Enter pwd

Terminate xcalc.

Set focus on the xcalc, and type your interrupt character (such as [CTRL-C]

2.3.3.2 Problem checklist

When I try to start a client, I see "connection refused by server" or "client is not authorized to connect to server."

You may need to run the xhost command. See your system administrator or an experienced X user.

When I try to start a client, I see "Error: Can't open display."

Your DISPLAY environment variable may not be set correctly or you may need to use the -display option. Ask for help or refer to the X Window System User's Guide, Volume 3.


Previous: 2.2 Starting XLearning the Unix Operating SystemNext: 2.4 Working with a Mouse
2.2 Starting XBook Index2.4 Working with a Mouse

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System