Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Aug 2017 12:08:39 +0000 (UTC)
From:      Ben Woods <woodsb02@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r447625 - in head/sysutils: . chvt chvt/files
Message-ID:  <201708091208.v79C8d91081610@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: woodsb02
Date: Wed Aug  9 12:08:39 2017
New Revision: 447625
URL: https://svnweb.freebsd.org/changeset/ports/447625

Log:
  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

Added:
  head/sysutils/chvt/
  head/sysutils/chvt/Makefile   (contents, props changed)
  head/sysutils/chvt/files/
  head/sysutils/chvt/files/chvt.c   (contents, props changed)
  head/sysutils/chvt/pkg-descr   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Wed Aug  9 12:01:10 2017	(r447624)
+++ head/sysutils/Makefile	Wed Aug  9 12:08:39 2017	(r447625)
@@ -154,6 +154,7 @@
     SUBDIR += cfengine38
     SUBDIR += cfengine39
     SUBDIR += chgrep
+    SUBDIR += chvt
     SUBDIR += chyves
     SUBDIR += cinnamon-control-center
     SUBDIR += cinnamon-settings-daemon

Added: head/sysutils/chvt/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/chvt/Makefile	Wed Aug  9 12:08:39 2017	(r447625)
@@ -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>

Added: head/sysutils/chvt/files/chvt.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/chvt/files/chvt.c	Wed Aug  9 12:08:39 2017	(r447625)
@@ -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;
+}

Added: head/sysutils/chvt/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/chvt/pkg-descr	Wed Aug  9 12:08:39 2017	(r447625)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708091208.v79C8d91081610>