aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
authorwoodsb02 <woodsb02@FreeBSD.org>2017-08-09 20:08:39 +0800
committerwoodsb02 <woodsb02@FreeBSD.org>2017-08-09 20:08:39 +0800
commita75bb3bc244033b2977d716df89a3c879ef71c81 (patch)
treeff8145beee42e568dc8f8d1202282cfe39ee7397 /sysutils
parentb378d5ef72a4b0abd8ed41f6dcc04b098079c627 (diff)
downloadfreebsd-ports-gnome-a75bb3bc244033b2977d716df89a3c879ef71c81.tar.gz
freebsd-ports-gnome-a75bb3bc244033b2977d716df89a3c879ef71c81.tar.zst
freebsd-ports-gnome-a75bb3bc244033b2977d716df89a3c879ef71c81.zip
Add new port sysutils/chvt
The command chvt N makes /dev/ttyv(N-1) the foreground terminal. The key combination Ctrl-Alt-FN (with N in the range 1-12) has a similar effect. WWW: https://lists.debian.org/debian-bsd/2009/11/msg00006.html
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/Makefile1
-rw-r--r--sysutils/chvt/Makefile36
-rw-r--r--sysutils/chvt/files/chvt.c68
-rw-r--r--sysutils/chvt/pkg-descr4
4 files changed, 109 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile
index b2450142d3c8..e36dc0a0937b 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -154,6 +154,7 @@
SUBDIR += cfengine38
SUBDIR += cfengine39
SUBDIR += chgrep
+ SUBDIR += chvt
SUBDIR += chyves
SUBDIR += cinnamon-control-center
SUBDIR += cinnamon-settings-daemon
diff --git a/sysutils/chvt/Makefile b/sysutils/chvt/Makefile
new file mode 100644
index 000000000000..e4fdcefbef78
--- /dev/null
+++ b/sysutils/chvt/Makefile
@@ -0,0 +1,36 @@
+# Created by: Ben Woods <woodsb02@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME= chvt
+PORTVERSION= 0.20091101
+CATEGORIES= sysutils
+MASTER_SITES= #
+DISTFILES= #
+
+MAINTAINER= woodsb02@FreeBSD.org
+COMMENT= Change foreground virtual terminal
+
+LICENSE= GNUALLPERMISSIVE
+LICENSE_NAME= GNU All-Permissive License
+LICENSE_TEXT= See https://www.gnu.org/prep/maintain/html_node/License-Notices-for-Other-Files.html
+LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+PLIST_FILES= bin/chvt
+
+OPTIONS_DEFINE= SETUID
+SETUID_DESC= Install setuid binary (does not require root priviledges)
+
+do-extract:
+ ${MKDIR} ${WRKSRC}
+# ${CP} ${FILESDIR}/chvt.c ${WRKSRC}/
+
+do-build:
+ cd ${WRKSRC} && ${CC} -o ${WRKSRC}/chvt ${FILESDIR}/chvt.c
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/chvt ${STAGEDIR}${PREFIX}/bin/chvt
+
+post-install-SETUID-on:
+ ${CHMOD} u+s ${STAGEDIR}${PREFIX}/bin/chvt
+
+.include <bsd.port.mk>
diff --git a/sysutils/chvt/files/chvt.c b/sysutils/chvt/files/chvt.c
new file mode 100644
index 000000000000..d114ad88489f
--- /dev/null
+++ b/sysutils/chvt/files/chvt.c
@@ -0,0 +1,68 @@
+/* chvt.c - change virtual terminal for [k]freebsd
+ Copyright (C) 2009 Werner Koch
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/consio.h>
+#include <errno.h>
+
+
+int
+main (int argc, char **argv)
+{
+ int fd, screen;
+
+ if (argc < 1 || argc > 2)
+ {
+ fputs ("Usage: chvt [VTNO]\n", stderr);
+ return 1;
+ }
+ if (argc == 2)
+ {
+ screen = atoi (argv[1]);
+
+ if (screen < 1 || screen > 11)
+ {
+ fprintf (stderr, "chvt: invalid screen numver %d\n", screen);
+ return 1;
+ }
+ }
+
+ fd = open ("/dev/ttyv0", O_RDWR, 0);
+ if (fd == -1)
+ {
+ fprintf (stderr, "chvt: error opening terminal: %s\n", strerror (errno));
+ return 1;
+ }
+ if (argc == 2)
+ {
+ if (ioctl (fd, VT_ACTIVATE, screen))
+ {
+ fprintf (stderr, "chvt: VT_ACTIVATE failed: %s\n", strerror (errno));
+ return 1;
+ }
+ }
+ else
+ {
+ if (ioctl (fd, VT_GETACTIVE, &screen))
+ {
+ fprintf (stderr, "chvt: VT_GETACTIVE failed: %s\n", strerror (errno));
+ return 1;
+ }
+ printf ("%d\n", screen);
+ }
+ return 0;
+}
diff --git a/sysutils/chvt/pkg-descr b/sysutils/chvt/pkg-descr
new file mode 100644
index 000000000000..b0908e90c523
--- /dev/null
+++ b/sysutils/chvt/pkg-descr
@@ -0,0 +1,4 @@
+The command chvt N makes /dev/ttyv(N-1) the foreground terminal.
+The key combination Ctrl-Alt-FN (with N in the range 1-12) has a similar effect.
+
+WWW: https://lists.debian.org/debian-bsd/2009/11/msg00006.html