diff options
author | David Krause <david@cvs.openbsd.org> | 2004-06-23 07:37:24 +0000 |
---|---|---|
committer | David Krause <david@cvs.openbsd.org> | 2004-06-23 07:37:24 +0000 |
commit | 647bc20a1fcc21da1a400e21379fc7414dd1223c (patch) | |
tree | 5677338689aa6acad9d5c8353f076c63c323aa61 /sbin | |
parent | 47269e8cc20b7f584ccefadc404c8d6ff329e1f6 (diff) |
make -w optional; ok miod@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/wsconsctl/wsconsctl.8 | 20 | ||||
-rw-r--r-- | sbin/wsconsctl/wsconsctl.c | 99 |
2 files changed, 55 insertions, 64 deletions
diff --git a/sbin/wsconsctl/wsconsctl.8 b/sbin/wsconsctl/wsconsctl.8 index 3af00ce0c14..1a56bee8bdc 100644 --- a/sbin/wsconsctl/wsconsctl.8 +++ b/sbin/wsconsctl/wsconsctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: wsconsctl.8,v 1.16 2003/11/07 09:00:43 jmc Exp $ +.\" $OpenBSD: wsconsctl.8,v 1.17 2004/06/23 07:37:23 david Exp $ .\" $NetBSD: wsconsctl.8,v 1.5 1999/09/12 18:47:11 kleink Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -50,11 +50,9 @@ .Ar name ... .Nm wsconsctl .Op Fl n -.Fl w .Ar name=value ... .Nm wsconsctl .Op Fl n -.Fl w .Ar name+=value ... .Sh DESCRIPTION The @@ -70,7 +68,7 @@ The options are as follows: Print all device variables and their current values. .It Fl n Suppress printing of the variable name in the output. -.It Fl w Ar name=value +.It Ar name=value Attempt to set the specified variable .Ar name to @@ -132,7 +130,7 @@ keyboard/mouse/display definitions .Sh EXAMPLES Set a UK keyboard encoding: .Pp -.Dl # wsconsctl -w keyboard.encoding=uk +.Dl # wsconsctl keyboard.encoding=uk .Pp Modify the current keyboard encoding so that, when the .Ar Caps Lock @@ -144,13 +142,13 @@ to the .Ar /usr/include/dev/wscons/wsksymdef.h file. .Pp -.Dl # wsconsctl -w keyboard.map+="keysym Caps_Lock = Control_L" +.Dl # wsconsctl keyboard.map+="keysym Caps_Lock = Control_L" .Pp Assign the .Ar Right Alt key to be the group modifier (layout is changed while the key is pressed): .Pp -.Dl # wsconsctl -w keyboard.map+="keycode 184=Mode_switch" +.Dl # wsconsctl keyboard.map+="keycode 184=Mode_switch" .Pp Assign the .Ar Right Control @@ -165,7 +163,7 @@ and .Ar Shift behaviour. .Pp -.Dl # wsconsctl -w keyboard.map+="keycode 157=Mode_Lock" +.Dl # wsconsctl keyboard.map+="keycode 157=Mode_Lock" .Pp Set a US keyboard encoding, with the .Ar Caps Lock @@ -180,15 +178,15 @@ by the .Ar Caps Lock key is enough \- see the previous example for details. .Pp -.Dl # wsconsctl -w keyboard.encoding=us.swapctrlcaps +.Dl # wsconsctl keyboard.encoding=us.swapctrlcaps .Pp Set the bell pitch to be 1200: .Pp -.Dl # wsconsctl -w keyboard.bell.pitch=1200 +.Dl # wsconsctl keyboard.bell.pitch=1200 .Pp Add 200 to the current pitch of the bell: .Pp -.Dl # wsconsctl -w keyboard.bell.pitch+=200 +.Dl # wsconsctl keyboard.bell.pitch+=200 .Sh SEE ALSO .Xr pckbd 4 , .Xr wscons 4 , diff --git a/sbin/wsconsctl/wsconsctl.c b/sbin/wsconsctl/wsconsctl.c index 9917cc79909..89c5908638d 100644 --- a/sbin/wsconsctl/wsconsctl.c +++ b/sbin/wsconsctl/wsconsctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.c,v 1.13 2003/07/10 00:00:58 david Exp $ */ +/* $OpenBSD: wsconsctl.c,v 1.14 2004/06/23 07:37:23 david Exp $ */ /* $NetBSD: wsconsctl.c,v 1.2 1998/12/29 22:40:20 hannken Exp $ */ /*- @@ -83,7 +83,7 @@ usage(char *msg) fprintf(stderr, "usage: %s [-n] name ...\n" - " %s [-n] -w name=value ...\n" + " %s [-n] name=value ...\n" " %s [-n] -a\n", __progname, __progname, __progname); @@ -94,13 +94,13 @@ int main(int argc, char *argv[]) { int i, ch, error; - int aflag, wflag; + int aflag; char *sep, *p; struct vartypesw *sw; struct field *f; int do_merge; - error = aflag = wflag = 0; + error = aflag = 0; sw = NULL; sep = "="; @@ -113,7 +113,7 @@ main(int argc, char *argv[]) sep = NULL; break; case 'w': - wflag = 1; + /* compat */ break; default: usage(NULL); @@ -125,8 +125,6 @@ main(int argc, char *argv[]) if (argc > 0 && aflag != 0) usage("excess arguments after -a"); - if (aflag != 0 && wflag != 0) - usage("only one of -a or -w may be given"); if (aflag != 0) { for (sw = typesw; sw->name; sw++) { @@ -151,52 +149,9 @@ main(int argc, char *argv[]) pr_field(sw->name, f, sep); } } else if (argc > 0) { - if (wflag != 0) - for (i = 0; i < argc; i++) { - p = strchr(argv[i], '='); - if (p == NULL) { - warnx("'=' not found"); - continue; - } - if (p > argv[i] && - (*(p - 1) == '+' || *(p - 1) == '-')) { - do_merge = *(p - 1); - *(p - 1) = '\0'; - } else - do_merge = 0; - *p++ = '\0'; - sw = tab_by_name(argv[i]); - if (!sw) - continue; - if (sw->fd < 0 && - (sw->fd = open(sw->file, O_WRONLY)) < 0 && - (sw->fd = open(sw->file, O_RDONLY)) < 0) { - warn("open: %s", sw->file); - error = 1; - continue; - } - f = field_by_name(sw->field_tab, argv[i]); - if (f->flags & FLG_DEAD) - continue; - if ((f->flags & FLG_RDONLY) != 0) { - warnx("%s: read only", argv[i]); - continue; - } - if (do_merge || f->flags & FLG_INIT) { - if ((f->flags & FLG_MODIFY) == 0) - errx(1, "%s: can only be set", - argv[i]); - f->flags |= FLG_GET; - (*sw->getval)(sw->name, sw->fd); - f->flags &= ~FLG_GET; - } - rd_field(f, p, do_merge); - f->flags |= FLG_SET; - (*sw->putval)(sw->name, sw->fd); - f->flags &= ~FLG_SET; - } - else - for (i = 0; i < argc; i++) { + for (i = 0; i < argc; i++) { + p = strchr(argv[i], '='); + if (p == NULL) { sw = tab_by_name(argv[i]); if (!sw) continue; @@ -217,7 +172,45 @@ main(int argc, char *argv[]) f->flags |= FLG_GET; (*sw->getval)(sw->name, sw->fd); pr_field(sw->name, f, sep); + continue; } + if (p > argv[i] && + (*(p - 1) == '+' || *(p - 1) == '-')) { + do_merge = *(p - 1); + *(p - 1) = '\0'; + } else + do_merge = 0; + *p++ = '\0'; + sw = tab_by_name(argv[i]); + if (!sw) + continue; + if (sw->fd < 0 && + (sw->fd = open(sw->file, O_WRONLY)) < 0 && + (sw->fd = open(sw->file, O_RDONLY)) < 0) { + warn("open: %s", sw->file); + error = 1; + continue; + } + f = field_by_name(sw->field_tab, argv[i]); + if (f->flags & FLG_DEAD) + continue; + if ((f->flags & FLG_RDONLY) != 0) { + warnx("%s: read only", argv[i]); + continue; + } + if (do_merge || f->flags & FLG_INIT) { + if ((f->flags & FLG_MODIFY) == 0) + errx(1, "%s: can only be set", + argv[i]); + f->flags |= FLG_GET; + (*sw->getval)(sw->name, sw->fd); + f->flags &= ~FLG_GET; + } + rd_field(f, p, do_merge); + f->flags |= FLG_SET; + (*sw->putval)(sw->name, sw->fd); + f->flags &= ~FLG_SET; + } } else usage(NULL); |