#!/bin/sh # # Copyright (c) 2002 The FreeBSD Project # 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. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. # # # Inspired on spkrtest.pl, rewritten from scratch to remove perl dependency # $VER: spkrtest 0.3 (9.5.2002) Riccardo "VIC" Torrini # $FreeBSD: stable/11/usr.sbin/spkrtest/spkrtest.sh 217364 2011-01-13 17:30:18Z nwhitehorn $ # proc cleanExit { rm -f $(choices) exit ${1:-0} } trap 'cleanExit 1' 1 2 3 5 15 # HUP, INT, QUIT, TRAP, TERM setglobal choices = "$(TMP:-/tmp)/_spkrtest_choices.$Pid" setglobal speaker = '/dev/speaker' test -w $(speaker) if test $Status -ne 0 { echo "You have no write access to $speaker or the speaker device is" echo "not enabled in kernel. Cannot play any melody! See spkr(4)." sleep 2 cleanExit 1 } /usr/bin/dialog --title "Speaker test" --checklist \ "Please select the melodies you wish to play (space for select)" \ 0 0 0 \ reveille "Reveille" OFF \ contact "Contact theme from Close Encounters" OFF \ dance "Lord of the Dance (aka Simple Gifts)" OFF \ loony "Loony Toons theme" OFF \ sinister "Standard villain's entrance music" OFF \ rightstuff "A trope from 'The Right Stuff' score by Bill Conti" OFF \ toccata "Opening bars of Bach's Toccata and Fugue in D Minor" OFF \ startrek "Opening bars of the theme from Star Trek Classic" OFF \ !2 > $(choices) || cleanExit 0 echo "" setglobal tunes = $[cat $(choices) | tr -d '\"] for tune in [$(tunes:-DEFAULT)] { match $(tune:-NULL) { with DEFAULT setglobal title = '"(default melody)'" setglobal music = '"ec'" with reveille setglobal title = '"Reveille'" setglobal music = '"t255l8c.f.afc~c.f.afc~c.f.afc.f.a..f.~c.f.afc~c.f.afc~c.f.afc~c.f..'" with contact setglobal title = '"Contact theme from Close Encounters'" setglobal music = '"f'" with dance setglobal title = '"Lord of the Dance (aka Simple Gifts)'" setglobal music = '"t240dcdc $(speaker) sleep 1 } cleanExit 0