mirror of
https://github.com/openbsd/src.git
synced 2024-12-21 23:18:00 -08:00
Add -g option to get the index of the current virtual terminal.
This can help scripts using wsconsctl display.focus to perform vt switches. From NetBSD via Sergiy Kopchalyuk.
This commit is contained in:
parent
c387b13259
commit
c18ef1e4e9
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: wsconscfg.8,v 1.20 2010/07/01 02:46:06 maja Exp $
|
||||
.\" $OpenBSD: wsconscfg.8,v 1.21 2024/11/06 17:14:03 miod Exp $
|
||||
.\" $NetBSD: wsconscfg.8,v 1.5 1999/05/15 14:45:06 drochner Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1999
|
||||
@ -25,7 +25,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 1 2010 $
|
||||
.Dd $Mdocdate: November 6 2024 $
|
||||
.Dt WSCONSCFG 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -33,7 +33,7 @@
|
||||
.Nd configure virtual terminals on a wscons display
|
||||
.Sh SYNOPSIS
|
||||
.Nm wsconscfg
|
||||
.Op Fl dFkm
|
||||
.Op Fl dFgkm
|
||||
.Op Fl e Ar emul
|
||||
.Op Fl f Ar ctldev
|
||||
.Op Fl t Ar type
|
||||
@ -41,7 +41,7 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
tool allows for the creation and removal of virtual terminals
|
||||
tool allows for the viewing, creation and removal of virtual terminals
|
||||
on display devices controlled by the wscons terminal framework,
|
||||
as long as the underlying display hardware driver supports multiple screens.
|
||||
Furthermore, it controls the assignment of keyboards to displays.
|
||||
@ -95,6 +95,12 @@ even if it is in use by a userspace program.
|
||||
Specify the control device of the wscons display to operate on.
|
||||
The default is
|
||||
.Pa /dev/ttyCcfg .
|
||||
.It Fl g
|
||||
Print the index of the virtual terminal specified by
|
||||
.Ar index .
|
||||
If the
|
||||
.Ar index
|
||||
argument is omitted, the index of the current virtual terminal is printed.
|
||||
.It Fl k
|
||||
Do keyboard related operations instead of virtual screen configuration.
|
||||
Without other flags, a keyboard will be attached to the display device.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: wsconscfg.c,v 1.18 2022/12/04 23:50:51 cheloha Exp $ */
|
||||
/* $OpenBSD: wsconscfg.c,v 1.19 2024/11/06 17:14:03 miod Exp $ */
|
||||
/* $NetBSD: wsconscfg.c,v 1.4 1999/07/29 18:24:10 augustss Exp $ */
|
||||
|
||||
/*
|
||||
@ -52,33 +52,38 @@ usage(void)
|
||||
extern char *__progname;
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-dFkm] [-e emul] [-f ctldev] [-t type] index\n",
|
||||
"usage: %s [-dFgkm] [-e emul] [-f ctldev] [-t type] index\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *wsdev;
|
||||
int c, delete, kbd, idx, wsfd, res, mux;
|
||||
int c, delete, get, kbd, idx, wsfd, res, mux;
|
||||
struct wsdisplay_addscreendata asd;
|
||||
struct wsdisplay_delscreendata dsd;
|
||||
struct wsmux_device wmd;
|
||||
|
||||
wsdev = DEFDEV;
|
||||
delete = 0;
|
||||
get = 0;
|
||||
kbd = 0;
|
||||
mux = 0;
|
||||
asd.screentype[0] = 0;
|
||||
asd.emul[0] = 0;
|
||||
dsd.flags = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "f:dkmt:e:F")) != -1) {
|
||||
while ((c = getopt(argc, argv, "f:dgkmt:e:F")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
wsdev = optarg;
|
||||
break;
|
||||
case 'g':
|
||||
get = 1;
|
||||
break;
|
||||
case 'd':
|
||||
delete = 1;
|
||||
break;
|
||||
@ -106,14 +111,15 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (kbd ? (argc > 1) : (argc != 1))
|
||||
if ((kbd && get) ||
|
||||
((kbd || get) ? (argc > 1) : (argc != 1)))
|
||||
usage();
|
||||
|
||||
idx = -1;
|
||||
if (argc > 0 && sscanf(argv[0], "%d", &idx) != 1)
|
||||
errx(1, "invalid index");
|
||||
|
||||
wsfd = open(wsdev, O_RDWR);
|
||||
wsfd = open(wsdev, get ? O_RDONLY : O_RDWR);
|
||||
if (wsfd < 0)
|
||||
err(2, "%s", wsdev);
|
||||
|
||||
@ -137,6 +143,13 @@ main(int argc, char *argv[])
|
||||
res = ioctl(wsfd, WSDISPLAYIO_DELSCREEN, &dsd);
|
||||
if (res < 0)
|
||||
err(3, "WSDISPLAYIO_DELSCREEN");
|
||||
} else if (get) {
|
||||
asd.idx = idx;
|
||||
res = ioctl(wsfd, WSDISPLAYIO_GETSCREEN, &asd);
|
||||
if (res < 0)
|
||||
err(3, "WSDISPLAYIO_GETSCREEN");
|
||||
else
|
||||
printf("%d\n", asd.idx);
|
||||
} else {
|
||||
asd.idx = idx;
|
||||
res = ioctl(wsfd, WSDISPLAYIO_ADDSCREEN, &asd);
|
||||
|
Loading…
Reference in New Issue
Block a user