X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fmultimedia%2Fplay_random.sh;h=a5df00939603978878af3ede9fa047d642595e9e;hb=refs%2Fheads%2Fmain;hp=b2e824fc19216bb203b3a01c0330ae98498215d5;hpb=dbe3a7d9104352d69efdaa5eca600908ecc9bba8;p=feisty_meow.git diff --git a/scripts/multimedia/play_random.sh b/scripts/multimedia/play_random.sh index b2e824fc..c4d3e446 100644 --- a/scripts/multimedia/play_random.sh +++ b/scripts/multimedia/play_random.sh @@ -1,31 +1,24 @@ -#!/bin/bash -hostfile=/etc/HOSTNAME -if [ ! -f "$hostfile" ]; then - hostfile=/etc/hostname -fi -if [ ! -f "$hostfile" ]; then - echo "Could not find the hostfile for this machine." - exit 3 -fi +#!/usr/bin/env bash + +# plays a random sound chosen from our sound library. + +#hmmm: very fred or feisty meow specific right now. -grunty=$(grep -i gruntose.blurgh <"$hostfile") -if [ ! -z "$grunty" ]; then +our_host="$(hostname -f)" + +# this will eat the entire hostname, if it's a member of our domain. +grunty="${our_host%%*gruntose.blurgh}" +#hmmm: generalize the above also. oy. + +# now check if we should play in our local host zone. +if [ -z "$grunty" ]; then VOXDIR=/z/walrus/media/sounds -#hmmm: generalize the above. - FILE_LIST=$(find $VOXDIR -type f) -#echo "file list is $FILE_LIST" - LINES=$(find $VOXDIR -type f | wc -l) -#echo "lines is $LINES" - LESS_CHANCE=$(expr $LINES \\* 4) -#echo "less chance is $LESS_CHANCE" - TO_PLAY= - while [ -z "$TO_PLAY" ]; do - TO_PLAY=$(find $VOXDIR -type f | random $LESS_CHANCE | tail -1) -#echo "to play is $TO_PLAY" - done - - # now play the file - bash $FEISTY_MEOW_SCRIPTS/sound_play.sh $TO_PLAY +#hmmm: generalize the above location. + + TO_PLAY="$(find $VOXDIR -type f | shuf | tail -n 1)" +echo "to play is $TO_PLAY" + # now play the file we randomly chose. + bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh $TO_PLAY fi