• Aucun résultat trouvé

% xterm -e mail

Dans le document How to Use This Book (Page 160-164)

When you quit the mail program, the xterm window exits.

The -e option needs to be the last xterm option on the command line. The remainder of the command line is assumed to be part of the command to be executed by xterm. The new window has the command name in its titlebar by default (unless overridden by other command-line options (Section 5.15)).

One use for xterm -e is for running a window with a login session to a remote system, like this:

% xterm -e ssh hostname &

Go to http://examples.oreilly.com/upt3 for more information on: ssh-agent

The xterm process runs on the local system, but immediately logs you into the remote machine. You are prompted for a password in the new xterm that pops up — before you can log in to the remote system.

This isn't as convenient as putting that command in your X setup file (like .xinitrc or .xsession) — but it's far more secure because you don't need to put your hostname in your .rhosts or .shosts file (Section 1.21), which is a potential security hole. (Or, if you use ssh for your remote login — and you start ssh-agent before you start X — you won't need to type passwords at all during your X session. This is the handiest setup by far.)

You can use -e to create a makeshift X display for any character-based programs you like to run. For example, you might want to keep track of messages sent to the console, but you can't run xterm -C to get console messages because you aren't actually logged in on the console. You might run something like this:

tail -f

Section 12.10

% xterm -e tail -f /var/log/messages &

Section 24.21 has more about how this works.

—LM, JP, and SJC

5.23 Don't Quote Arguments to xterm -e

Being a belt-and-suspenders kind of guy, I've gotten in the habit of quoting arguments to commands. This makes good sense with lots of Unix shell commands, but it can get you in trouble with xterm -e. For example, I wanted to set up a job that would open vi in a window to edit a file named .postit. At first, I

used the command:

xterm ... -e 'vi .postit' &

only to receive the perplexing message in the resulting window:

Can't execvp vi .postit

The quotes passed the entire string to xterm as an argument, which parsed it as a single command name, rather than a command plus argument. Removing the quotes solved the problem.

—TOR and SJC

[1] When we refer to terminals throughout this and other chapters, understand that we mean, more often than not, the set of standard terminal-emulation control codes implemented by terminal emulators, such as vt100 or ANSI color. So, though we may refer to a vt100 terminal, we're more likely referring to any terminal-emulator software that can understand and react to that set of control codes.

[2] getty is spawned by the init at multiuser system startup, and it sets up all ttys, handles the initial login prompt, and then hands successful logins over to login to complete.

[3] Sure, you don't have to worry about whether there is a local TYMNET dialup nowadays, but back in the day . . .

[4] Note that there is no user named stucklogin; you're expected to supply the actual login username as an argument to su.

[5] . . . for some values of "modern", anyway . . . — SJC

[6] When we refer, throughout the rest of the chapter, to xterm, we're often referring to xterm proper, as well as rxvt and other related terminal programs.

[7] Since there can be only one CLIPBOARD selection at a time, you can only run one xclipboard per display.

[8] If you're using a terminal emulator other than xterm, the program should also allow this sort of customization. See the client manpage for the actions (the equivalents of

select-end

and

insert-selection

) to include in the translation table.

[9] By this time, the observant reader will have concluded that xclipboard is a nuisance at best.

CONTENTS

CONTENTS

Chapter 6. Your X Environment

6.1 Defining Keys and Button Presses with xmodmap 6.2 Using xev to Learn Keysym Mappings

6.3 X Resource Syntax 6.4 X Event Translations

6.5 Setting X Resources: Overview

6.6 Setting Resources with the -xrm Option 6.7 How -name Affects Resources

6.8 Setting Resources with xrdb

6.9 Listing the Current Resources for a Client: appres 6.10 Starting Remote X Clients

6.1 Defining Keys and Button Presses with xmodmap

If you have a Linux system, you may want to use loadkeys instead of xmodmap. loadkeys is designed to set the keymap used by the system as a whole, particularly the console, so use your own judgment.

Whatever is done in xmodmap will affect X but not the system console.

An important piece to the X Window System puzzle is filled by the xmodmap client. When the user performs any action — such as typing a key or moving the mouse — the server sends a packet of

information to the client called an event. These events are then translated into actions by the client. You can use the xmodmap utility to effectively change the event that is reported to the client.

Keysym mappings are mappings of keyboard events at the server level, before the event is sent to the client. Keysyms are the symbols used for each key on the keyboard.

The X server maintains a keymap table, which contains a listing of keys on the keyboard and how they should be interpreted. A client gets the keymap table from the server upon client startup. In most cases, the keymap table is used to interpret keys literally — when you press the letter "a," a key code is sent to the client that corresponds to the letter "a" in the keymap table.

You can use the xmodmap client to reassign key codes within the keymap table. xmodmap can therefore be used to redefine how the key is interpreted by the client. You probably wouldn't want to translate the alphanumeric keys on the keyboard, but you may want to translate others. For example, you might want to change the BACKSPACE key to DELETE:

% xmodmap -e "keysym BackSpace = Delete"

Another example is if you mistakenly hit the CAPS LOCK key a bit too often, you can disable it

completely. Some people might disable CAPS LOCK the low-tech way (by just removing the key from the keyboard!), but you can also render it harmless with the command:

% xmodmap -e "keysym Caps_Lock = "

effectively disabling the CAPS LOCK key entirely. Note that the symbol is now gone and can't be redefined without using the hardware key code.

If you are a DVORAK typist, you can use xmodmap to translate every key on the keyboard and so your QWERTY keyboard behaves like a DVORAK keyboard.

If it ever seems that keystrokes are not working correctly, you can check current keysym settings by running xmodmap with the -pk argument. Use the xev client to determine exactly which key code a key generates on your display. There is also a public domain client called xkeycaps that can be used to display the keysyms for selected keyboards.

You can use xmodmap to add or remove keysyms, or even to redefine the key code associated with that keysym. You can also use it to redefine the mouse buttons, using the

pointer

keyword. For example, to have the second and third mouse button switch places, you can enter:

% xmodmap -e "pointer = 1 3 2"

If you have a large number of keys to remap, you can put the commands in a file that is read when your X session starts. For example, create a file called .Xmodmap:

Dans le document How to Use This Book (Page 160-164)

Documents relatifs