summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING2
-rw-r--r--man/xload.man17
-rw-r--r--xload.c26
3 files changed, 35 insertions, 10 deletions
diff --git a/COPYING b/COPYING
index 8ddad19..01b7d7a 100644
--- a/COPYING
+++ b/COPYING
@@ -26,7 +26,7 @@ from the X Consortium.
----------------------------------------
-Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
diff --git a/man/xload.man b/man/xload.man
index 358d162..89adade 100644
--- a/man/xload.man
+++ b/man/xload.man
@@ -3,11 +3,12 @@
.SH NAME
xload \- system load average display for X
.SH SYNOPSIS
-\fBxload\fP [-\fItoolkitoption\fP ...] [-scale \fIinteger\fP] [-update \fIseconds\fP]
-.br
- [-hl \fIcolor\fP] [-highlight \fIcolor\fP] [-remote \fIhost\fP]
-.br
- [-jumpscroll \fIpixels\fP] [-label \fIstring\fP] [-nolabel] [-lights]
+.nf
+\fBxload\fP [-\fItoolkitoption\fP ...] [-scale \fIinteger\fP] [-update \fIseconds\fP]
+ [-hl \fIcolor\fP] [-highlight \fIcolor\fP] [-remote \fIhost\fP]
+ [-jumpscroll \fIpixels\fP] [-label \fIstring\fP] [-nolabel] [-lights]
+ [-help|-version]
+.fi
.SH DESCRIPTION
The
.I xload
@@ -57,6 +58,12 @@ is 1 second. The default is 10.
.TP 8
.B \-remote \fIhost\fP
This option tells \fIxload\fP to display the load of \fIhost\fP instead of \fIlocalhost\fP. \fIXload\fP gets the information from the \fIrwhod\fP database and consequently requires \fIrwhod\fP to be executing both on \fIlocalhost\fP and \fIhost\fP.
+.TP 8
+.B \-help
+This option specifies that \fIxload\fP should print a usage message and exit.
+.TP 8
+.B \-version
+This option specifies that \fIxload\fP should print version info and exit.
.SH RESOURCES
In addition to the resources available to each of the widgets used by
\fIxload\fP there is one resource defined by the application itself.
diff --git a/xload.c b/xload.c
index 0559769..73d675f 100644
--- a/xload.c
+++ b/xload.c
@@ -28,7 +28,7 @@ from the X Consortium.
*/
/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -140,7 +140,7 @@ static int light_update = 10 * 1000;
*/
static void _X_NORETURN
-usage(void)
+usage(int exitval)
{
fprintf (stderr, gettext("usage: %s [-options ...]\n\n%s\n"),
ProgramName, gettext(
@@ -157,8 +157,10 @@ usage(void)
" -nolabel removes the label from above the chart.\n"
" -jumpscroll <value> number of pixels to scroll on overflow\n"
" -lights use keyboard leds to display current load\n"
+ " -help print this message\n"
+ " -version print version info\n"
));
- exit(1);
+ exit(exitval);
}
int
@@ -175,6 +177,22 @@ main(int argc, char **argv)
ProgramName = argv[0];
+ /* Handle args that don't require opening a display or load info source */
+ 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);
+ }
+ }
+
/* For security reasons, we reset our uid/gid after doing the necessary
system initialization and before calling any X routines. */
InitLoadPoint();
@@ -213,7 +231,7 @@ main(int argc, char **argv)
fprintf(stderr, " %s", argv[n]);
}
fputs("\n\n", stderr);
- usage();
+ usage(1);
}
XtGetApplicationResources( toplevel, (XtPointer) &resources,