diff options
-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | man/xkbbell.man | 48 | ||||
-rw-r--r-- | man/xkbvleds.man | 51 | ||||
-rw-r--r-- | man/xkbwatch.man | 18 | ||||
-rw-r--r-- | utils.c | 31 | ||||
-rw-r--r-- | utils.h | 10 | ||||
-rw-r--r-- | xkbbell.c | 8 | ||||
-rw-r--r-- | xkbvleds.c | 14 | ||||
-rw-r--r-- | xkbwatch.c | 32 |
11 files changed, 103 insertions, 123 deletions
@@ -46,7 +46,7 @@ used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. -Copyright (c) 2008, Oracle and/or its affiliates. +Copyright (c) 2008, 2025, 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"), @@ -1,11 +1,11 @@ -xkbutils is a collection of small utilities utilizing the XKeyboard (XKB) +xkbutils is a collection of small utilities utilizing the X Keyboard (XKB) extension to the X11 protocol. It includes: - * xkbbell - generate XKB bell events - * xkbvleds - display the state of LEDs on an XKB keyboard in a window - * xkbwatch - reports changes in the XKB keyboard state + * xkbbell - generate X Keyboard Extension bell events + * xkbvleds - display X Keyboard Extension LED state in a window + * xkbwatch - report state changes using the X Keyboard Extension All questions regarding this software should be directed at the Xorg mailing list: diff --git a/configure.ac b/configure.ac index 5f3473a..0cbfc40 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl Process this file with autoconf to create configure. # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([xkbutils], [1.0.5], +AC_INIT([xkbutils], [1.0.6], [https://gitlab.freedesktop.org/xorg/app/xkbutils/issues], [xkbutils]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) @@ -38,8 +38,6 @@ m4_ifndef([XORG_MACROS_VERSION], XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS -AC_CHECK_FUNCS([strcasecmp]) - # xkbvleds checks PKG_CHECK_MODULES(XKBVLEDS, [xproto >= 7.0.17 xaw7 xt x11]) diff --git a/man/xkbbell.man b/man/xkbbell.man index d0069f0..a1bc8ce 100644 --- a/man/xkbbell.man +++ b/man/xkbbell.man @@ -1,4 +1,4 @@ -.\" Copyright (c) 2008, Oracle and/or its affiliates. +.\" Copyright (c) 2008, 2025, 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"), @@ -18,67 +18,51 @@ .\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING .\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER .\" DEALINGS IN THE SOFTWARE. -.TH xkbbell __appmansuffix__ __xorgversion__ +.TH XKBBELL __appmansuffix__ 2024-05-31 __xorgversion__ .SH NAME -xkbbell - XKB extension user utility +xkbbell \- generate X Keyboard Extension bell events .SH SYNOPSIS -.B xkbbell -[-display <dpy>] -[-synch] -[-dev <id>] -[-force] -[-nobeep] -[-bf <id>] -[-kf <id>] -[-v <volume>] -[-w <id>] -[-help|-version] +.nf +\fBxkbbell\fP [\fB\-display\fP \fIdpy\fP] [\fB\-synch\fP] [\fB-dev\fP \fIid\fP] \ +[\fB\-force\fP] [\fB\-nobeep\fP] + [\fB\-bf\fP \fIid\fP] [\fB-kf\fP \fIid\fP] [\fB-v\fP \fIvolume\fP] [\fB\-w\fP \fIid\fP] [\fB\-help\fP|\fB\-version\fP] +.fi .SH DESCRIPTION user utility .SH OPTIONS -.PP .TP 8 -.B \-display <dpy> +.B \-display \fIdpy\fP specifies which display to use .TP 8 .B \-synch turns on synchronization -.PP .TP 8 -.B \-dev <id> +.B \-dev \fIid\fP specifies which device to use -.PP .TP 8 .B \-force force audible bell -.PP .TP 8 .B \-nobeep suppress server bell, event only -.PP .TP 8 -.B \-bf <id> +.B \-bf \fIid\fP specifies which bell feedback to use -.PP .TP 8 -.B \-kf <id> +.B \-kf \fIid\fP specifies which keyboard feedback to use -.PP .TP 8 -.B \-v <volume> +.B \-v \fIvolume\fP specifies which volume to use -.PP .TP 8 -.B \-w <id> +.B \-w \fIid\fP specifies which window to use -.PP .TP 8 .B \-help print list of options and exit -.PP .TP 8 .B \-version print program version and exit .PP -If neither device nor feedback are specified, xkbbell uses the default values -for the core keyboard device. +If neither device nor feedback are specified, +xkbbell uses the default values for the core keyboard device. diff --git a/man/xkbvleds.man b/man/xkbvleds.man index 913f009..f4078af 100644 --- a/man/xkbvleds.man +++ b/man/xkbvleds.man @@ -1,4 +1,4 @@ -.\" Copyright (c) 2008, Oracle and/or its affiliates. +.\" Copyright (c) 2008, 2025, 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"), @@ -18,66 +18,53 @@ .\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING .\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER .\" DEALINGS IN THE SOFTWARE. -.TH xkbvleds __appmansuffix__ __xorgversion__ +.TH XKBVLEDS __appmansuffix__ 2024-05-31 __xorgversion__ .SH NAME -xkbvleds \- XKB extension user utility +xkbvleds \- display X Keyboard Extension LED state in a window .SH SYNOPSIS -.B xkbvleds -[\-indpy <name>] -[\-watch <leds>] -[[\-+]automatic] -[[\-+]explicit] -[[\-+]name] -[[\-+]real] -[[\-+]virtual] -[\-intersection] -[\-union] +.nf +\fBxkbvleds\fP [\fB\-indpy\fP \fIname\fP] [\fB\-watch\fP \fIleds\fP] \ +[\fB\-intersection\fP] [\fB\-union\fP] + [\fB+automatic\fP|\fB\-automatic\fP] [\fB+explicit\fP|\fB\-explicit\fP] \ +[\fB+name\fP|\fB\-name\fP] + [\fB+real\fP|\fB\-real\fP] [\fB+virtual\fP|\fB\-virtual\fP] +.fi .SH DESCRIPTION This program is used to display the state of LEDs on an XKB keyboard. It reports the changes in the fundamental components of the XKB state -which includes the effective compatibility state. The default set of LEDs -is \-union +name +automatic +real. +which includes the effective compatibility state. +The default set of LEDs is \fB\-union +name +automatic +real\fP. .SH OPTIONS -.PP .TP 8 -.B \-indpy <name> +.B \-indpy \fIname\fP Mask of LEDs to watch .TP 8 -.B \-watch <leds> +.B \-watch \fIleds\fP turn on synchronization -.PP .TP 8 -.B \[-+]automatic +.BR \-automatic " | " +automatic (Don't) watch automatic LEDs -.PP .TP 8 -.B \[-+]explicit +.BR \-explicit " | " +explicit (Don't) watch explicit LEDs -.PP .TP 8 -.B \[-+]name +.BR \-name " | " +name (Don't) watch named LEDs -.PP .TP 8 -.B \[-+]real +.BR \-real " | " +real (Don't) watch real LEDs -.PP .TP 8 -.B \[-+]virtual +.BR \-virtual " | " +virtual (Don't) watch virtual LEDs -.PP .TP 8 .B \-intersection Watch only LEDs in all desired sets -.PP .TP 8 .B \-union Watch LEDs in any desired sets -.PP .TP 8 .B \-help print list of options and exit -.PP .TP 8 .B \-version print program version and exit diff --git a/man/xkbwatch.man b/man/xkbwatch.man index a17be95..379c496 100644 --- a/man/xkbwatch.man +++ b/man/xkbwatch.man @@ -1,4 +1,4 @@ -.\" Copyright (c) 2008, Oracle and/or its affiliates. +.\" Copyright (c) 2008, 2025, 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"), @@ -18,19 +18,23 @@ .\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING .\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER .\" DEALINGS IN THE SOFTWARE. -.TH xkbwatch __appmansuffix__ __xorgversion__ +.TH XKBWATCH __appmansuffix__ 2025-04-05 __xorgversion__ .SH NAME -xkbwatch - XKB extension user utility +xkbwatch \- report state changes using the X Keyboard Extension .SH DESCRIPTION This program reports changes in the fundamental components of the XKB keyboard state plus the effective compatibility state. .SH OPTIONS -.I Xkbwatch +.B Xkbwatch accepts all of the standard X Toolkit command line options along with the additional options listed below: .TP 8 +.B \-help +This option indicates that the program usage should be printed, +after which the program exits. +.TP 8 .B \-version -This option indicates that the program version should be printed, after -which the program exits. +This option indicates that the program version should be printed, +after which the program exits. .SH "SEE ALSO" -X(__miscmansuffix__) +.BR X (__miscmansuffix__) @@ -123,34 +123,3 @@ uInternalError(const char *s, ...) va_end(ap); return; } - -/***====================================================================***/ - -#ifndef HAVE_STRCASECMP -int -uStrCaseCmp(const char *str1, const char *str2) -{ - char buf1[512], buf2[512]; - char c, *s; - - register int n; - - for (n = 0, s = buf1; (c = *str1++); n++) { - if (isupper(c)) - c = tolower(c); - if (n > 510) - break; - *s++ = c; - } - *s = '\0'; - for (n = 0, s = buf2; (c = *str2++); n++) { - if (isupper(c)) - c = tolower(c); - if (n > 510) - break; - *s++ = c; - } - *s = '\0'; - return (strcmp(buf1, buf2)); -} -#endif @@ -39,6 +39,7 @@ #include <X11/Xfuncs.h> #include <stdarg.h> #include <stddef.h> +#include <strings.h> _XFUNCPROTOBEGIN @@ -64,13 +65,12 @@ extern void uInternalError(const char *s, ...) _X_ATTRIBUTE_PRINTF(1,2); /***====================================================================***/ +#if defined(_MSC_VER) +#define strcasecmp _stricmp +#endif + #define uStrCaseEqual(s1,s2) (uStrCaseCmp(s1,s2)==0) -#ifdef HAVE_STRCASECMP #define uStrCaseCmp(s1,s2) (strcasecmp(s1,s2)) -#else -extern int uStrCaseCmp(const char * /* s1 */, - const char * /* s2 */); -#endif /***====================================================================***/ @@ -65,10 +65,12 @@ parseArgs(int argc, char *argv[]) } } else if ((strcmp(argv[i], "-help") == 0) || + (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-usage") == 0)) { return 0; } - else if (strcmp(argv[i], "-version") == 0) { + else if ((strcmp(argv[i], "-version") == 0) || + (strcmp(argv[i], "--version")) == 0) { printf("xkbbell (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION); exit(0); } @@ -146,6 +148,10 @@ parseArgs(int argc, char *argv[]) return 0; } } + else if (argv[i][0] == '-') { + fprintf(stderr, "Unrecognized argument: %s\n", argv[i]); + return 0; + } else { if (i < argc - 1) { fprintf(stderr, "Bell name must be the last argument\n"); @@ -59,7 +59,7 @@ static Bool useUnion = True; /***====================================================================***/ static void -usage(char *program) +usage(const char *program) { uInformation("Usage: %s <options>\n", program); uInformation("Legal options include the usual X toolkit options plus:\n" @@ -115,11 +115,13 @@ parseArgs(int argc, char *argv[]) else if (uStrCaseEqual(argv[i], "-intersection")) { useUnion = False; } - else if (uStrCaseEqual(argv[i], "-help")) { + else if (uStrCaseEqual(argv[i], "-help") || + (strcmp(argv[i], "--help") == 0)) { usage(argv[0]); exit(0); } - else if (uStrCaseEqual(argv[i], "-version")) { + else if (uStrCaseEqual(argv[i], "-version") || + (strcmp(argv[i], "--version") == 0)) { printf("xkbvleds (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION); exit(0); } @@ -139,7 +141,11 @@ parseArgs(int argc, char *argv[]) which = &wantReal; else if (uStrCaseEqual(&argv[i][1], "virtual")) which = &wantVirtual; - if (which != NULL) { + if (which == NULL) { + fprintf(stderr, "Unrecognized argument: %s\n", argv[i]); + return 0; + } + else { if (*which != DONT_CARE) { uWarning("Multiple settings for [+-]%s\n", &argv[i][1]); uAction("Using %c%s, ignoring %c%s\n", @@ -78,11 +78,27 @@ main(int argc, char *argv[]) "*Box*vSpace: 1", NULL }; + static const char * const usage = + "Usage: xkbwatch [-options ...]\n" + "\n" + "where options include all standard toolkit options plus:\n" + " -help Print usage message and exit\n" + " -version Print version and exit\n"; - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-version") == 0) { + /* Handle args that don't require opening a display */ + for (int a = 1; a < argc; a++) { + const char *argn = argv[a]; + /* accept single or double dash for -help & -version */ + if (argn[0] == '-' && argn[1] == '-') { + argn++; + } + if (strcmp(argn, "-help") == 0) { + fputs(usage, stdout); + exit(EXIT_SUCCESS); + } + if (strcmp(argn, "-version") == 0) { printf("xkbwatch (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION); - exit(0); + exit(EXIT_SUCCESS); } } @@ -94,6 +110,16 @@ main(int argc, char *argv[]) uFatalError("Couldn't create application top level\n"); exit(1); } + if (argc > 1) { + fputs("Unrecognized argument(s):", stderr); + for (int a = 1; a < argc; a++) { + fprintf(stderr, " %s", argv[a]); + } + fputs("\n\n", stderr); + fputs(usage, stderr); + exit(EXIT_FAILURE); + } + inDpy = outDpy = XtDisplay(toplevel); if (inDpy) { int i1, mn, mj; |