File: listen.sh

package info (click to toggle)
mgetty 1.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,880 kB
  • sloc: ansic: 42,728; sh: 6,487; perl: 6,262; makefile: 1,457; tcl: 756; lisp: 283
file content (102 lines) | stat: -rw-r--r-- 2,892 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#/bin/sh
#
# From: ELBERS@bng.nl (H.D. Elbers)
# Date: Thu, 12 Dec 1996 12:16:46 +0100 (MET)
# Cc: helbers@solair1.inter.NL.net (H.D. Elbers)
#
# Hello Marc,
#
# Since it wasn't possible to play the recorded messages from my Elsa modem
# on my soundblaster with the pvftools used in the "listen" script I hacked it
# a bit to use an external microphone which is connected to the soundblaster.
# I also externded the script with a "played" directory containing compressed
# already played messages.
# Perhaps you can use it for the next vgetty-distribution?
#
# Greetings, Henk.
#
VOICEDIR=/usr/spool/voice/incoming
VM="vm play -s"
MIXER=~/sound/sndkit/mixer
DIALOG=dialog
FLAG=.flag
FILES=va*.rmd
ZFILES=va*.rmd.gz

play_msg()
{
    $DIALOG </dev/tty --title "PLAYING FILE" --infobox \
     "Playing $choice\npress [space] to skip" 5 51
    trap "" SIGINT
    stty quit ' '
    $MIXER vol 100 > /dev/null 2>&1
    $MIXER mic 100 > /dev/null 2>&1
    rm -f /var/lock/LCK..ttyS1
    $VM $choice
    echo $$ > /var/lock/LCK..ttyS1
    $MIXER mic 0   > /dev/null 2>&1
    $MIXER vol 80  > /dev/null 2>&1
    stty sane
    trap SIGINT
}

if [ -f /var/lock/LCK..ttyS1 ]
then
    echo "modem is locked..."
    exit 1
fi
echo $$ > /var/lock/LCK..ttyS1
cd $VOICEDIR
DONE=no
while [ $DONE = "no" ]
do
    if $DIALOG </dev/tty --clear --title "PLAY VOICE" \
     --menu "Pick a voice file to play" 20 51 14 \
     `ls -lt $FILES 2>/dev/null \
     | awk '{ printf("%s %s-%s-%s-(%dk)\n",$9,$6,$7,$8,$5/1024) }'` \
     played 'already played messages' 2> /tmp/menu.tmp.$$;\
    then
     choice=`cat /tmp/menu.tmp.$$`
     if [ $choice = "played" ]
     then
         cd $VOICEDIR/played
         P_DONE=no
         while [ $P_DONE = "no" ]
         do
          if $DIALOG </dev/tty --clear --title "PLAY VOICE" \
              --menu "Pick a voice file to play" 20 51 14 \
              `ls -lt $ZFILES 2>/dev/null | awk \
              '{ printf("%s %s-%s-%s-(%dk)\n",$9,$6,$7,$8,$5/1024) }'` \
              2> /tmp/menu.tmp.$$;
          then
              choice=`cat /tmp/menu.tmp.$$`
              gunzip < $choice > /tmp/menu.rmd.$$
              choice=/tmp/menu.rmd.$$
              play_msg
              rm $choice
          else
              P_DONE=yes
          fi
         done
         cd $VOICEDIR
     else
         play_msg
         if $DIALOG </dev/tty --clear --title "DELETE FILE" \
              --menu $choice 10 60 3 \
              1 "keep message" \
              2 "move message to $VOICEDIR/played" \
              3 "delete message" 2> /tmp/menu.tmp.$$
         then
          ans=`cat /tmp/menu.tmp.$$`
          if [ $ans -eq 2 ];then mv $choice played;gzip played/$choice;fi
          if [ $ans -eq 3 ];then rm $choice;fi
         fi
     fi
    else
     $DIALOG --clear
     DONE=yes
     rm -f $FLAG
    fi
    rm -f /tmp/menu.tmp.$$
done
rm -f /var/lock/LCK..ttyS1