gpm - a cut and paste utility and mouse server for virtual consoles
gpm [ options ]
This package tries to be a useful mouse server for applications running on the Linux console. It is based on the “selection” package, and some of its code comes from selection itself. This package is intended as a replacement for “selection” as a cut-and-paste mechanism; it also provides additional facilities. The “selection” package offered the first cut-and-paste implementation for Linux using two mouse buttons, and the cut buffer is still called “selection buffer” or just “selection" throughout this document. The information below is extracted from the texinfo file, which is the preferred source of information.
The gpm executable is meant to act like a daemon (thus, gpmd would be a better name for it). This section is meant to describe the command-line options for gpm, while its internals are outlined in the next section.
Due to restrictions in the ioctl(TIOCLINUX) system call, gpm must be run by the superuser. The restrictions have been added in the last 1.1 kernels to fix a security hole related to selection and screen dumping.
The server can be configured to match the user’s taste, and any application using the mouse will inherit the server’s attitude. From release 1.02 up to 1.19.2 is was possible for any user logged on the system console to change the mouse feeling using the -q option. This is no longer possible for security reasons.
As of 0.97 the server program puts itself in the background. To kill gpm you can just reinvoke it with the -k cmdline switch, although killall gpm can be a better choice.
Version 1.10 adds the capability to execute special commands on certain circumstances. Special commands default to rebooting and halting the system, but the user can specify his/her personal choice. The capability to invoke commands using the mouse is a handy one for programmers, because it allows to issue a clean shutdown when the keyboard is locked and no network is available to restore the system to a sane state.
Special commands are toggled by triple-clicking the left and right button -- an unlikely event during normal mouse usage. The easiest way to triple-click is pressing one of the buttons and triple-click the other one. When special processing is toggled, a message appears on the console (and the speaker beeps twice, if you have a speaker); if the user releases all the buttons and presses one of them again within three seconds, then the special command corresponding to the button is executed.
The default special commands are:
Reboot the system by signalling the init process
middle button (if any)
Execute /sbin/shutdown -h now
Execute /sbin/shutdown -r now
The -S command line switch enables special command processing and allows to change the three special commands. To accept the default commands use -S “” (i.e., specify an empty argument). To specify your own commands, use a colon-separated list to specify commands associated to the left, middle and right button. If any of the commands is empty, it is interpreted as ‘send a signal to the init process’. This particular operation is supported, in addition to executing external commands, because sometimes bad bugs put the system to the impossibility to fork; in these rare case the programmer should be able to shutdown the system anyways, and killing init from a running process is the only way to do it.
As an example, -S “:telinit 1:/sbin/halt", associates killing init to the left button, going single user to the middle one, and halting the system to the right button.
System administrators should obviously be careful about special commands, as gpm runs with superuser permissions. Special commands are best suited for computers whose mouse can be physically accessed only by trusted people.
Available command line options are the following:
case $( /usr/bin/tty ) in
/dev/tty[0-9]*) /usr/bin/disable-paste ;; esac
Use -t after you selected the mouse device with -m.
To select text press the left mouse button and drag the mouse. To paste text in the same or another console, press the middle button. The right button is used to extend the selection, like in ‘xterm’.
Two-button mice use the right button to paste text.
Double and triple clicks select whole word and whole lines. Use of the ‘-p’ option is recommended for best visual feedback.
If a trailing space after the contents of a line is highlighted, and if there is no other text on the remainder of the line, the rest of the line will be selected automatically. If a number of lines are selected, highlighted trailing spaces on each line will be removed from the selection buffer.
Any output on the virtual console holding the selection will clear the highlighted selection from the screen, to maintain integrity of the display, although the contents of the paste buffer will be unaffected.
The selection mechanism is disabled if the controlling virtual console is placed in graphics mode, for example when running X11, and is reenabled when text mode is resumed. (But see BUGS section below.)
The gpm server may have problems interacting with X: if your mouse is a single-open device (i.e. a bus mouse), you should kill gpm before starting X, or use the -R option (see above). To kill gpm just invoke gpm -k. This problem doesn’t apply to serial mice.
Two instances of gpm can’t run on the same system. If you have two mice use the -M option (see above).
While the current console is in graphic mode, gpm sleeps until text mode is back (unless -R is used). Thus, it won’t reply to clients. Anyways, it is unlikely that mouse-eager clients will spur out in hidden consoles.
The clients shipped out with gpm are not updated, thus there are potential security risks when using them.
Andrew Haylett <email@example.com> (the original selection code) Ian Zimmerman <firstname.lastname@example.org> (old maintainer) Alessandro Rubini <email@example.com> (old maintainer (still helps a lot)) Nico Schottelius <firstname.lastname@example.org> (maintainer)
Many many contributors, to both selection and gpm.
The current maintainer is Nico Schottelius. But without the help of Alessandro Rubini and the mailing list it would be impossible for him to maintain gpm. The development mailing list can be reached under email@example.com. More information on the list is in the README file part of the source distribution of gpm.
/var/run/gpm.pid The PID of the running gpm
The info file about ‘gpm’, which gives more complete information and explains how to write a gpm client.
Table of Contents