Permalink
Browse files

Initial import of autocue-20060128 into the Packages Collection.

	autocue is a program which takes a simple text file as input, and
	outputs its contents, broken up into paragraphs, and formatted by fmt,
	into xcb's cut buffers.  From there, the text can be pasted with a
	simple mouse click.  autocue will then wait for a period of time
	relative to the size of the text, before moving onto the next
	paragraph. Successive cut buffers will be used, and then will wrap
	to the beginning.

	The speed can be varied whilst the program is running - by sending
	a SIGUSR1 to the process, autocue will go faster. Sending a SIGUSR2
	to the process will make it go slower.

	This program can be used to scroll a presentation, along with timing
	information (a beep is sounded when the next buffer should be pasted),
	and the presenter can simply paste into the presentation window.
  • Loading branch information...
1 parent 697da71 commit 5b8d22d5b2523558605a89c736113f3dee9d41cc agc committed Jan 28, 2006
View
@@ -0,0 +1,15 @@
+autocue is a program which takes a simple text file as input, and
+outputs its contents, broken up into paragraphs, and formatted by fmt,
+into xcb's cut buffers. From there, the text can be pasted with a
+simple mouse click. autocue will then wait for a period of time
+relative to the size of the text, before moving onto the next
+paragraph. Successive cut buffers will be used, and then will wrap
+to the beginning.
+
+The speed can be varied whilst the program is running - by sending
+a SIGUSR1 to the process, autocue will go faster. Sending a SIGUSR2
+to the process will make it go slower.
+
+This program can be used to scroll a presentation, along with timing
+information (a beep is sounded when the next buffer should be pasted),
+and the presenter can simply paste into the presentation window.
View
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $
+#
+
+DISTNAME= autocue-20060128
+CATEGORIES= misc
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= agc@NetBSD.org
+HOMEPAGE= http://www.alistaircrooks.co.uk/software.html
+COMMENT= Time-based text formatter, sending output to xcb for pasting
+
+DEPENDS+= xcb-[0-9]*:../../x11/xcb
+
+do-extract:
+ @${CP} -R ${FILESDIR} ${WRKSRC}
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/autocue ${PREFIX}/bin
+ ${INSTALL_MAN} ${WRKSRC}/autocue.1 ${PREFIX}/man/man1
+
+.include "../../mk/bsd.pkg.mk"
View
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $
+bin/autocue
+man/man1/autocue.1
@@ -0,0 +1,2 @@
+$NetBSD: distinfo,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $
+
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $
+
+PROG= autocue
+SRCS= autocue.c
+MKMAN= no
+WARNS= 4
+
+.include <bsd.prog.mk>
@@ -0,0 +1,97 @@
+.\" $NetBSD: autocue.1,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $
+.\"
+.\" Copyright © 2006 Alistair Crooks. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. The name of the author may not be used to endorse or promote
+.\" products derived from this software without specific prior written
+.\" permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd January 28, 2006
+.Dt AUTOCUE 1
+.Os
+.Sh NAME
+.Nm autocue
+.Nd display text in X11 cut buffers timed depending on size of text
+.Sh SYNOPSIS
+.Nm
+.Op Fl S Ar speed
+.Op Fl c Ar maxcut
+.Op Fl s Ar symbolic-speed
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+utility reads a text input file, and sends formatted output
+to the X11 cut buffers by using the
+.Ar xcb
+utility.
+.Nm
+will then wait for a period of time (dependent upon the speed
+settings), before sending the next paragraph of text to the next cut
+buffers.
+.Pp
+The options are as follows:
+.Bl -tag -width maxcuts
+.It Fl S Ar speed
+Takes a numeric value for speed, which is the number of characters
+per second that the text can be read.
+See also the
+.Ar s
+argument for some pre-defined rates.
+Slow readers can generally read at 3 characters per second, medium
+at 7 characters per second, and fast readers at 10 or more characters per
+second.
+.It Fl c Ar maxcut
+Provides the maximum number of X11 cut buffers whihc will be used.
+.It Fl s Ar speed
+Provides pre-computed
+.Ar fast ,
+.Ar medium and
+.Ar slow
+definitions for the speed.
+.Pp
+If
+.Nm
+is going too fast, then a SIGUSR2 signal
+delivered via
+.Xr kill 1
+will make it go one
+character per second slower.
+If
+.Nm
+is going too slowly, then a SIGUSR1 signal
+delivered via
+.Xr kill 1
+will make it go
+one character per second faster.
+.El
+.Sh EXIT STATUS
+The
+.Nm
+utility exits 0 on success, and \*[Gt]0 if an error occurs.
+.Sh SEE ALSO
+.Xr kill 1
+.Sh AUTHOR
+The
+.Nm
+was written by Alistair Crooks (agc@NetBSD.org).
@@ -0,0 +1,158 @@
+/* $NetBSD: autocue.c,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $ */
+
+/*
+ * Copyright © 2006 Alistair Crooks. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+
+#ifndef lint
+__COPYRIGHT("@(#) Copyright © 2006 \
+ The NetBSD Foundation, Inc. All rights reserved.");
+__RCSID("$NetBSD: autocue.c,v 1.1.1.1 2006/01/28 20:47:22 agc Exp $");
+#endif
+
+#include <err.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* symbolic constants */
+enum {
+ MaxCutBuffers = 4,
+
+ FmtGoal = 50,
+ FmtMax = 55,
+
+ SlowDenom = 3,
+ MediumDenom = 7,
+ FastDenom = 10
+};
+
+static int speed;
+
+/* send process a USR1 to make the display go faster */
+static void
+sigusr1(int s)
+{
+ printf("moving from speed %d to %d (faster)\n", speed, speed + 1);
+ speed += 1;
+}
+
+/* send process a USR2 to make the display go slower */
+static void
+sigusr2(int s)
+{
+ printf("moving from speed %d to %d (slower)\n", speed, speed - 1);
+ speed -= 1;
+}
+
+/* show the contents of the buffer `buf', which is `cc' chars long */
+/* maxcut is the number of xcb cut buffers you have displayed */
+/* speed is a numeric value for the number of seconds denominator */
+static void
+showbuffer(char *buf, int cc, int maxcut)
+{
+ static int cut;
+ char cmd[BUFSIZ];
+ FILE *pp;
+ int s;
+
+ (void) snprintf(cmd, sizeof(cmd), "fmt %d %d | xcb -s %d", FmtGoal, FmtMax, cut);
+ if ((pp = popen(cmd, "w")) == NULL) {
+ errx(EXIT_FAILURE, "can't open pipe to xcb");
+ }
+ buf[cc] = 0x0;
+ (void) fprintf(pp, "%s", buf);
+ (void) pclose(pp);
+ s = cc / speed;
+ printf("%.20s...\nBuffer contents are in cut buffer %d, sleeping %d secs\a\n", buf, cut, s);
+ while ((s = sleep(s)) > 0) {
+ }
+ cut = (cut + 1) % maxcut;
+}
+
+int
+main(int argc, char **argv)
+{
+ char buf[BUFSIZ * 20];
+ char line[BUFSIZ];
+ FILE *fp;
+ int maxcut;
+ int cc;
+ int c;
+ int i;
+
+ maxcut = MaxCutBuffers;
+ speed = SlowDenom;
+ signal(SIGUSR1, sigusr1);
+ signal(SIGUSR2, sigusr2);
+ while ((i = getopt(argc, argv, "S:c:s:")) != -1) {
+ switch(i) {
+ case 'S':
+ speed = atoi(optarg);
+ break;
+ case 'c':
+ maxcut = atoi(optarg);
+ break;
+ case 's':
+ if (strcmp(optarg, "slow") == 0) {
+ speed = SlowDenom;
+ } else if (strcmp(optarg, "medium") == 0) {
+ speed = MediumDenom;
+ } else if (strcmp(optarg, "fast") == 0) {
+ speed = FastDenom;
+ }
+ break;
+ }
+ }
+ if (argc - optind < 1) {
+ errx(EXIT_FAILURE, "Usage: %s [-S numeric-speed] [-c max cut buffers] [-s speed] file", *argv);
+ }
+ if (speed == 0) {
+ err(EXIT_FAILURE, "Speed cannot be '0'");
+ }
+ if (maxcut == 0) {
+ err(EXIT_FAILURE, "Maximum cut buffers cannot be '0'");
+ }
+ if ((fp = fopen(argv[optind], "r")) == NULL) {
+ errx(EXIT_FAILURE, "can't open `%s'", argv[optind]);
+ }
+ printf("send this process - %d - a USR1 to make the display go faster, a USR2 to make it go slower\n", getpid());
+ for (cc = 0 ; fgets(line, sizeof(line), fp) != NULL ; ) {
+ if (line[0] == '\n') {
+ showbuffer(buf, cc, maxcut);
+ cc = 0;
+ continue;
+ }
+ c = strlen(line);
+ (void) memcpy(&buf[cc], line, c);
+ cc += c;
+ }
+ exit(EXIT_SUCCESS);
+}

0 comments on commit 5b8d22d

Please sign in to comment.