turns printfs back on
[freebsd-src/fkvm-freebsd.git] / usr.sbin / spkrtest / spkrtest.sh
blobc682b03f43acc823a2bfacbca20bd15d506d20f5
1 #!/bin/sh
4 # Copyright (c) 2002 The FreeBSD Project
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 # SUCH DAMAGE.
30 # Inspired on spkrtest.pl, rewritten from scratch to remove perl dependency
31 # $VER: spkrtest 0.3 (9.5.2002) Riccardo "VIC" Torrini <riccardo@torrini.org>
32 # $FreeBSD$
35 cleanExit() {
36 rm -f ${choices}
37 exit ${1:-0}
40 trap 'cleanExit 1' 1 2 3 5 15 # HUP, INT, QUIT, TRAP, TERM
42 choices=${TMP:-/tmp}/_spkrtest_choices.$$
43 speaker=/dev/speaker
45 test -w ${speaker}
46 if [ $? -ne 0 ]
47 then
48 echo "You have no write access to $speaker or the speaker device is"
49 echo "not enabled in kernel. Cannot play any melody! See spkr(4)."
50 sleep 2
51 cleanExit 1
54 /usr/bin/dialog --title "Speaker test" --checklist \
55 "Please select the melodies you wish to play (space for select)" \
56 -1 -1 10 \
57 reveille "Reveille" OFF \
58 contact "Contact theme from Close Encounters" OFF \
59 dance "Lord of the Dance (aka Simple Gifts)" OFF \
60 loony "Loony Toons theme" OFF \
61 sinister "Standard villain's entrance music" OFF \
62 rightstuff "A trope from 'The Right Stuff' score by Bill Conti" OFF \
63 toccata "Opening bars of Bach's Toccata and Fugue in D Minor" OFF \
64 startrek "Opening bars of the theme from Star Trek Classic" OFF \
65 2> ${choices} || cleanExit 0
67 echo ""
68 tunes="`cat ${choices} | tr -d '\"'`"
69 for tune in ${tunes:-DEFAULT}
71 case ${tune:-NULL} in
72 DEFAULT)
73 title="(default melody)"
74 music="ec"
76 reveille)
77 title="Reveille"
78 music="t255l8c.f.afc~c.f.afc~c.f.afc.f.a..f.~c.f.afc~c.f.afc~c.f.afc~c.f.."
80 contact)
81 title="Contact theme from Close Encounters"
82 music="<cd<a#~<a#>f"
84 dance)
85 title="Lord of the Dance (aka Simple Gifts)"
86 music="t240<cfcfgagaa#b#>dc<a#a.~fg.gaa#.agagegc.~cfcfgagaa#b#>dc<a#a.~fg.gga.agfgfgf."
88 loony)
89 title="Loony Toons theme"
90 music="t255cf8f8edc<a>~cf8f8edd#e~ce8cdce8cd.<a>c8c8c#def8af8"
92 sinister)
93 title="standard villain's entrance music"
94 music="mst200o2ola.l8bc.~a.~>l2d#"
96 rightstuff)
97 title="a trope from 'The Right Stuff' score by Bill Conti"
98 music="olcega.a8f>cd2bgc.c8dee2"
100 toccata)
101 title="opening bars of Bach's Toccata and Fugue in D Minor"
102 music="msl16oldcd4mll8pcb-agf+4.g4p4<msl16dcd4mll8pa.a+f+4p16g4"
104 startrek)
105 title="opening bars of the theme from Star Trek Classic"
106 music="l2b.f+.p16a.c+.p l4mn<b.>e8a2mspg+e8c+f+8b2"
108 esac
109 echo "Title: ${title}"
110 echo ${music} > ${speaker}
111 sleep 1
112 done
113 cleanExit 0