|
NAMEratmen - create a menu to run commandsSYNOPSISratmen [OPTION]... MENUITEM COMMAND...ratmen [OPTION]... {-d##|--delimiter ##} MENUITEM##COMMAND ... DESCRIPTIONRatmen is a simple program that accepts a list of MENUITEM and COMMAND pairs on the command line. It creates a window that consists of nothing but a menu. When a particular MENUITEM is selected by the user, the corresponding COMMAND is executed or (using --print) printed on standard output.Menu items and commands may either be given separately (as in ratmenu) using two arguments for each menu option, or, optionally you may specify a delimiter (using the --delimiter option) and specify both menu item and command in the same argument (similar to 9menu). The delimiter may be of any length. If the command is omitted (or if an empty command is supplied when not using --delimiter) then the menu item text will be used as the command. OPTIONSSome options may be specified using X resouces (allowing you to define some defaults you like in your in you ~/.Xresources, ~/.Xdefaults or similar). To make this mechanism as useful as possible I would suggest that you refrain from using such options on the command line, unless you really need to, and instead enable/disable the corresponding X resource setting.ratmen's default resource class is the name of the executed file, either ratmen or, if the executable was called through a link, the name of the link in question. The command line option --class may be used to override the default X resource class name.
KEYSTROKESThe Up keystrokes move the selection to the next item up. The Down keystrokes move the selection to the next item down. When the selection reaches the top or bottom, it scrolls around to the other side on pressing of the appropriate keystroke. The Select keystrokes execute the command corresponding to the currently selected menu item, and exit ratmen. The Back keystrokes does nothing unless the --back option was used, in which case it will run the command specified by that option and exit ratmen. The Exit keystrokes quit ratmen without doing anything.Up "k", Up_arrow, BackSpace, "-" Down "j", Down_arrow, Space, Tab, "+" Select "l", Right_arrow, Return Back "h", Left_arrow Exit "q", Escape MOUSE SUPPORTRatmen implements limited support for the rodent, you may select an item (left), go to any previous menu, given by --back, (right) or abort the menu (any other; usually middle). The mouse cannot be used to scroll the menu.Your rodent won't interfere with the normal operation. If you place the pointer on the menu by mistake, simply move it outside of the menu to restore the selection. You may, however, use the keys to manipulate an entry selected with the mouse, in this case the key based selection sticks. Actions are performed upon releasing a mouse butten. To cancel an action after the button has been pressed, move it outside the menu window and release the button (this goes for all the buttons). EXAMPLESHow about creating a little remote shell menu? The ratmenuish approach would beratmen --label Remotes xterm "" acme "rsh acme xterm" herman "rsh herman 9term" & and to do it the 9menu way, type something like ratmen --label Remotes -d: xterm "acme:rsh acme xterm" "herman:rsh herman 9term" & to do the trick. You could also make a menu containing some nice X programs to run. Like this: ratmen --label "X progs" ghostview "" xdvi "" xeyes "" xneko "" & Or like this: ratmen --label -d: "X progs" ghostview xdvi xeyes xneko & That last one is a bit easier on the eyes, don't you think? If you want, you can use the --back to call an "earlier" menu, like this: ratmen --back ~/bin/mypreviousmenu "X Eyes" xeyes & If you'd like to use a menu from within a shell script (a similar technique may of course be employed from any other programming language, such as perl) you could use the following: choice=`ratmen -pd: Abort Retry Ignore` Now any of the options selected will be put into the environment variable `$choice' (note, though, that this may also be empty if the user cancelled the menu). Here -p (or --print) option is used to print the selected COMMAND to standard out instead of running it, and -d (or --delimiter) is used simply to avoid having to fill out the command line with a lot of ugly "" arguments. (You could, of course, replace the colon in the command line with any character that you don't use in the menu.) And here are some lines from my ~/.Xresources file, for those interested: ! ratmen ratmen*foreground: yellow ratmen*font: -adobe-courier-medium-r-normal-*-18-*-*-*-m-*-iso8859-1 ratmen*unfocusExit: true This makes my menus easily distinguishable (since not much else is yellow in my system configuration), easily readable (since I like courier) and doesn't clutty my screen too much in case I happen to forget about them and go about doing something else instead of choosing and item from the menu. SEE ALSO/etc/X11/rgb.txt where you may find the names of appropriate colours to use with the --background and --forground options and X resources.AUTHORSThe initial idea for this program was by Arnold Robbins, after having worked with John Mackin's GWM Blit emulation. Matty Farrow wrote a version using libXg, from which some ideas were borrowed. This code was written by David Hogan and Arnold Robbins. Rich Salz motivated the -shell option. Jonathan Walther modified this code to play nicely with the ratpoison window manager by removing handling of mouse events and iconification.Zrajm C Akfogh <ratmen-mail@klingonska.org> changed command line syntax into the more standard getopts, added scrolling capacity if menu is to large to fit all at once, added --delimiter, --item, --print, --scroll-offset and --unfocus-exit options and X resource support (Yay! No need to specify those longish font-thingies on the command line any more!). The name `ratmen' is both an abbreviation of `ratmenu' (from which this program is heavily derived) and a reference to the fact that *I* don't have any religious reasons for not using the rodent (I like the keyboard, but I also like freedom of choice). FUTUREI have not activelly made any changes to this program for several years, though it was originally my intention to write a program that works both under X, and in the console.I later wrote termmen, which much closer resembles my intentions for ratmen, but unfortunately only works in the console or terminal (i.e. does not pop up a window of its own under X). Both termmen and this program is available from <http://zrajm.klingonska.org/programs/>. This program is written in C, which is not my native language, while Termmen is written as a zsh script. If anyone would like to continue development of ratmen, or a have a patch they'd like applied. Please feel free to send it to me at ratmen-mail@klingonska.org. HISTORY[2003-02-21, 12:47-16:18] Implemented `--item' for choosing initially selected item. Menu item and command is now given in the same string, separated with :, which makes for nicer error detection and lesser errors since it is a bit easier to keep track of what does which on the command line.[2003-02-22, 15:38-16:43] [2003-02-23, 02:19-02:36] Implemented `--delimiter' which now must be used to get the "menuitem:command" (as opposed to "menuitem" "command") behaviour. This, because I realised that when called from a script using an on-the-fly generated menu it can be quite tedious to make sure that the delimiter does not occur in the `menuitem' string (and thus fuck up the menu). Of course in handwritten menus the delimiter approach is easier to handle, hence I allow for both. Delimiter now also may be more than one character long. [2003-02-23, 19:08-20:30] Implemented --unfocus-exit which exits the menu if it's window is unfocused. [2003-02-23, 21:12-21:22] [2003-02-24, 00:22-00:49] [2003-02-24, 11:38-17:47] Now reads some options regulating appearance and behaviour from X resources in addition to the command line. [2003-02-25, 18:47-22:20] Wrote POD. At last found a really good name for the product. The ratmen. [2003-02-26, 01:38-09:15] Now reads command line option using getopt; thusly supports both --long-options and short ones (and bundles of short ones). Yay! Still haven't been able to get the --unfocus-exit to work properly. [2003-02-26, 13:27-14:34] Fixxed --unfocus-exit so that it now really makes the menu die of unfocus. Unfortunately, however a `BadWindow' message is generated by X when doing so, which looks quite ugly in ratpoison (which faithfully reports the error). I simply haven't been able to figure out what command is causing this, but my best guess is that there's some unlucky X function still queued which tries to manipulate the window after it has been closed. [2003-03-03, 00:13-01:54] Added the --print option, which can be extremely useful in scripts and other programs where you want to use a menu for some kind of input, rather than for a platform from which to fire off some program. Added "BUGS" section below. Added the --debug option which (as of now) dumps some info on the events (key/mouse clicks focusing etc.) intercepted from X. [2003-03-08, 11:21-11:29] Added a declaration of the subroutine `strcasecmp' and thus eliminating a compiler warning. Program worked flawlessy even before (and still does) but with less annoyance for me.. =|:-) The declaration thingy was found on the 'net by googling for "strcasetmp introduction". Made arguments to --align and --style case insensetive. [2003-03-08, 20:27-22:58] Found and killed a bug which made X resources override the command line options. [2003-03-09, 07:04-10:15] Totally fixed the bug mentioned in previous comment. Added short options -l, -c and -r (for left, center and right aligning of the menu text), and changed --label to --title. Also changed the size of the menu window so that it will always be an even number of text lines (looks pretty ogly when only half or a third of the last item can be seen). Opening of window could be still more optimal though (the problem still arises when X refuses to open the window with the requested height, e.g. when one uses frames in ratpoison). [2003-03-10, 00:53-04:07] v2.0 - Optimized menu redrawing routine for the non-scrolling case (used to flicker quite nastily when moving down large menus fast). Also finally got around to add scrolling capacity for menus too large to fit all at once. Added the related --scroll-offset option and X resource as well. [2003-03-10, 22:10-23:00] v2.0.1 - Begun fixxing window size bug (interrupted by Buffy - The Vampire Slayer). [2003-03-11, 00:31-04:25] [2003-03-12, 00:13-01:14] v2.0.2 - Fixed weird update/redraw bug thingy. Used to get a totally black empty menu sometimes. Bug probably introduced in last session, and now deceased. [2003-03-19, 10:48-12:38] [2003-03-19, 14:17-20:18] v2.1 - Wrote better handling of X resources, comlete with readable --debug output and all. [2003-03-19, 22:40-09:05] v2.2 - Implemented mouse support. Made --item=0 special. Bugfix: Now opens a window of the correct size by telling X that it wants a window whose vertical size should be any number of pixels evenly dividable by the font height. (Rxvt served as a source of inspiration for this feature.) Also added keys Home/PgUp for going to the first item in the menu and End/PgDn to go to the last. --class now really works. [2003-03-24, 15:41-16:32] v2.2.1 - Added options --mouse and --no-mouse and the corresponding X resource ratmen.mouse -- mouse is enabled by default. Removed the short options -u and -U (synonyms for --unfocus-exit and --no-unfocus-exit) as to not encourage the useage of those options on the command line (should be set using X resources). [2003-03-28, 11:29-11:32] v2.2.2 - Killed bug which didn't allow spaces to be used in font names (this little bugfix also makes it quite necessary not to end your X resources in any extraneous spaces). [2007-10-25, 11:23-14:13] v2.2.3 -- Bugfix. Changed a couple of latin-1 characters 173 (soft hyphens) to the minus signs the should have been all the time. Added the "FUTURE" heading above. Rewrote the Makefile. BUGS
TODOThese are the things a want to do next in approximate order of priority:
Visit the GSP FreeBSD Man Page Interface. |