summaryrefslogtreecommitdiff
path: root/xeyes.c
diff options
context:
space:
mode:
Diffstat (limited to 'xeyes.c')
-rw-r--r--xeyes.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/xeyes.c b/xeyes.c
index 5fea24b..a13f0d5 100644
--- a/xeyes.c
+++ b/xeyes.c
@@ -44,24 +44,23 @@ from the X Consortium.
/* Exit with message describing command line format */
static void _X_NORETURN
-usage(void)
+usage(int exitval)
{
fprintf(stderr,
- "usage: xeyes\n"
- " [-display [{host}]:[{vs}]]\n"
- " [-geometry [{width}][x{height}][{+-}{xoff}[{+-}{yoff}]]]\n"
- " [-fg {color}] [-bg {color}] [-bd {color}] [-bw {pixels}]\n"
- " [-shape | +shape] [-outline {color}] [-center {color}]\n"
- " [-backing {backing-store}] [-distance]\n");
+ "usage: xeyes [-display [{host}]:{vs}]\n"
+ " [-geometry [{width}][x{height}][{+-}{xoff}[{+-}{yoff}]]]\n"
+ " [-fg {color}] [-bg {color}] [-bd {color}] [-bw {pixels}]\n"
+ " [-shape | +shape] [-outline {color}] [-center {color}]\n"
+ " [-backing {backing-store}] [-distance]\n"
#ifdef XRENDER
- fprintf(stderr,
- " [-render | +render]\n");
+ " [-render | +render]\n"
#endif
#ifdef PRESENT
- fprintf(stderr,
- " [-present | +present]\n");
+ " [-present | +present]\n"
#endif
- exit(1);
+ " xeyes -help\n"
+ " xeyes -version\n");
+ exit(exitval);
}
/* Command line options table. Only resources are entered here...there is a
@@ -113,10 +112,27 @@ main(int argc, char **argv)
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
+ /* Handle args that don't require opening a display */
+ for (int n = 1; n < argc; n++) {
+ const char *argn = argv[n];
+ /* accept single or double dash for -help & -version */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-help") == 0) {
+ usage(0);
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
toplevel = XtAppInitialize(&app_context, "XEyes",
options, XtNumber(options), &argc, argv,
NULL, arg, (Cardinal) 0);
- if (argc != 1) usage();
+ if (argc != 1)
+ usage(1);
wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
False);