PMQUERY(1) | General Commands Manual | PMQUERY(1) |
pmconfirm, pmmessage, pmquery - general purpose dialog box
pmconfirm [-c] [-b button-name]
[-B default-button-name] [-t string]
[-file filename] [-icon icontype] [-font
font] [-header titlebar-string] [-useslider]
[-noslider] [-noframe] [-exclusive]
pmmessage [-buttons
label1[:value1][,label2[:value2][,...]]]
[-center] [-nearmouse] [-default button]
[-file filename] [-print] [-timeout sec]
message...
pmquery [-input] [all above options...] [message...]
pmquery provides a command-line-option compatible implementation of the xconfirm and xmessage tools, using a look-and-feel that is consistent with pmchart. Several extensions to the functionality of the original tools have been made, in order to improve their specific utility for pmchart, but wherever possible the original semantics remain.
pmconfirm displays a line of text for each -t option specified (or a file when the -file option is used), and a button for each -b option specified. When one of the buttons is pressed, the label of that button is written to pmquery's standard output. This provides a means of communication/feedback from within shell scripts and a means to display useful information to a user from an application.
pmmessage displays a window containing a message from the command line, a file, or standard input. It additionally allows buttons to be associated with an exit status, and only optionally will write the label of the button to standard output.
pmquery extends the above tools to additionally support limited user input, as free form text. In this -input mode, any text entered will be output when the default button is pressed. A default text can be entered using the same mechanisms as the other tools.
Command line options are available to specify font style, frame style, modality and one of several different icons to be presented for tailored visual feedback to the user.
The available command line options are:
The following shell script will display a window with an information icon, asking the user a yes or no question with "Yes" as the default.
#! /bin/sh
case `pmquery -t "Really power down?" -b No -B Yes -icon question
in
Yes) shutdown;;
No) ;;
esac
A second example, which prompts for a hostname then starts a terminal with an ssh session connected to the requested host.
#! /bin/sh
host=`pmquery -input -icon host -b Cancel -B OK \
-header "Remote Terminal - Secure Shell"
[ "$host" = "Cancel" -o -z "$host" ] && exit
gnome-terminal -e "ssh $host"
pmquery is an excellent choice of utility for the PCP_XCONFIRM_PROG Performance Co-Pilot configuration parameter (refer to pcp.conf(5) for details).
Note that PCP_XCONFIRM_PROG will be automatically set to pmquery inside tools like pmchart, unless PCP_XCONFIRM_PROG is already set in the environment.
If it detects an error, pmquery always returns 1, so this value should not be associated with a button. Unless -button option has not been used, the return code will be zero on success.
pmchart(1) and pcp.conf(5).
Performance Co-Pilot |