first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / multimedia / play_random.sh
1 #!/bin/bash
2 hostfile=/etc/HOSTNAME
3 if [ ! -f "$hostfile" ]; then
4   hostfile=/etc/hostname
5 fi
6 if [ ! -f "$hostfile" ]; then
7   echo "Could not find the hostfile for this machine."
8   exit 3
9 fi
10
11 grunty=$(grep -i gruntose.blurgh <"$hostfile")
12 if [ ! -z "$grunty" ]; then
13   VOXDIR=/z/walrus/media/sounds
14 #hmmm: generalize the above.
15   FILE_LIST=$(find $VOXDIR -type f)
16 #echo "file list is $FILE_LIST"
17   LINES=$(find $VOXDIR -type f | wc -l)
18 #echo "lines is $LINES"
19   LESS_CHANCE=$(expr $LINES \\* 4)
20 #echo "less chance is $LESS_CHANCE"
21   TO_PLAY=
22   while [ -z "$TO_PLAY" ]; do
23     TO_PLAY=$(find $VOXDIR -type f | random $LESS_CHANCE | tail -1)
24 #echo "to play is $TO_PLAY"
25   done
26
27   # now play the file
28   bash $SHELLDIR/sound_play.sh $TO_PLAY
29
30 fi
31