From 61820e8839a44cd7e0bbda688bc911363ba354d7 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 23 Jul 1995 01:46:55 +0000 Subject: [PATCH] Better version of spkrtest using perl and dialog Submitted by: Wolfram Schneider --- usr.sbin/spkrtest/Makefile | 7 +-- usr.sbin/spkrtest/spkrtest.8 | 32 ++++++++++++ usr.sbin/spkrtest/spkrtest.pl | 96 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 usr.sbin/spkrtest/spkrtest.8 create mode 100644 usr.sbin/spkrtest/spkrtest.pl diff --git a/usr.sbin/spkrtest/Makefile b/usr.sbin/spkrtest/Makefile index 84571d013581..57fa82263f8c 100644 --- a/usr.sbin/spkrtest/Makefile +++ b/usr.sbin/spkrtest/Makefile @@ -1,7 +1,8 @@ -NOMAN= noman +MAN8= spkrtest.8 +NOOBJ= yes beforeinstall: - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/spkrtest.sh ${DESTDIR}/${BINDIR}/spkrtest + install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/spkrtest.pl ${DESTDIR}${BINDIR}/spkrtest .include diff --git a/usr.sbin/spkrtest/spkrtest.8 b/usr.sbin/spkrtest/spkrtest.8 new file mode 100644 index 000000000000..056e0b4de28a --- /dev/null +++ b/usr.sbin/spkrtest/spkrtest.8 @@ -0,0 +1,32 @@ +.Dd May, 1995 +.Dt SPKRTEST 8 +.Os FreeBSD + +.Sh NAME +.Nm spkrtest +.Nd test script for the speaker driver + +.Sh DESCRIPTION +.Nm +is an easy to use test script for the speaker driver. + +.Sh FILES +.Bl -tag -width /dev/speakerxx +.It Pa /dev/speaker +speaker device file +.El + +.Sh SEE ALSO +.Xr spkr 4 , +.Xr dialog 1 , +.Xr perl 1 + +.\" only for the record +.\" .Sh AUTHOR +.\" Eric S. Raymond , May 1995 + +.Sh HISTORY +The +.Nm +script appeared in FreeBSD 1.0 diff --git a/usr.sbin/spkrtest/spkrtest.pl b/usr.sbin/spkrtest/spkrtest.pl new file mode 100644 index 000000000000..d0fe260924ad --- /dev/null +++ b/usr.sbin/spkrtest/spkrtest.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl +# +# Test script for the speaker driver +# +# v1.0 by Eric S. Raymond (Feb 1990) +# v1.1 rightstuff contributed by Eric S. Tiedemann (est@snark.thyrsus.com) +# v2.0 dialog+perl by Wolfram Schneider , May 1995 +# +# NOTE for iso-* (latin1) fonts: use TERM=cons25-iso8859-1 +# + +$title = " +reveille -- Reveille +contact -- Contact theme from Close Encounters +dance -- Lord of the Dance (aka Simple Gifts) +loony -- Loony Toons theme +sinister -- standard villain's entrance music +rightstuff -- a trope from \"The Right Stuff\" score by Bill Conti +toccata -- opening bars of Bach's Toccata and Fugue in D Minor +startrek -- opening bars of the theme from Star Trek Classic +"; + +$music = " +reveille -- t255l8c.f.afc~c.f.afc~c.f.afc.f.a..f.~c.f.afc~c.f.afc~c.f.afc~c.f.. +contact -- f +dance -- t240dcdc~cf8f8edd#e~ce8cdce8cd.c8c8c#def8af8 +sinister -- mst200o2ola.l8bc.~a.~>l2d# +rightstuff -- olcega.a8f>cd2bgc.c8dee2 +toccata -- msl16oldcd4mll8pcb-agf+4.g4p4e8a2mspg+e8c+f+8b2 +"; + +$checklist = 'dialog \ +--title "Speaker test" \ +--checklist "Please select the melodies you wish to play (space for select)" \ +-1 -1 10 \ +'; + + +sub Exit { + unlink $tmp if $tmp; +} + +$SIG{'INT'} = $SIG{'HUP'} = $SIG{'TRAP'} = $SIG{'QUIT'} = + $SIG{'TERM'} = '&Exit'; + + +# make assoc array from variable 'var' +# 'name -- description' -> $var{$name} = $description +sub splitconfig { + local(*var) = @_; + local($t, $name, $description); + + foreach $t (split('\n', $var)) { + ($name, $description) = split('--', $t); + + $name =~ s/^\s+//; $name =~ s/\s+$//; + $description =~ s/\s+//; $description =~ s/\s+$//; + + $var{$name} = $description if $name && $description; + } +} + +&splitconfig(*title); +&splitconfig(*music); + +foreach $e (sort keys %title) { + ($t = $title{$e}) =~ s/(\")/\\$1/g; # quote '"' + $checklist .= "\"$e\" \"$t\" OFF "; +} + +$tmp = ($ENV{'TMP'} || "/tmp") . "/_spkrtest$$"; +system("$checklist 2> $tmp"); # start dialog + +if (!$?) { # not cancel + open(SPEAKER, ">/dev/speaker") || die "/dev/speaker: $!\n"; + select(SPEAKER); $| = 1; + select(STDOUT); $| = 1; + + if (! -z $tmp) { # select melod(y/ies) + foreach $melody (split($", `cat $tmp`)) { + $melody =~ s/^"//; $melody =~ s/"$//; + print STDOUT "$title{$melody}\n"; + print SPEAKER "$music{$melody}"; + sleep 1; + } + } else { # use default melody + $melody = (sort keys %title)[0]; + print STDOUT "Use default melody: $title{$melody}\n"; + print SPEAKER "$music{$melody}"; + } + close SPEAKER; +} + +unlink $tmp;