diff options
| -rwxr-xr-x | speakerSqueaker.sh | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/speakerSqueaker.sh b/speakerSqueaker.sh index 17fe511..6b5dc58 100755 --- a/speakerSqueaker.sh +++ b/speakerSqueaker.sh @@ -18,7 +18,7 @@ # | pipe # awk ruturns just the third word (the number) -maxAmp=$(rec -d -c1 -n trim 0 .1 stat 2>&1 | grep 'Maximum amp' | awk {'print $3'}) +maxAmp=$(rec -d -c1 -n trim 0 .5 stat 2>&1 | grep 'Maximum amp' | awk {'print $3'}) # xprintidle is logfile eyecandy. Not necessary for the script to work echo $(xprintidle) Max Amplitude = "$maxAmp" | \ @@ -27,14 +27,16 @@ echo $(xprintidle) Max Amplitude = "$maxAmp" | \ if [ "$maxAmp" == "0.000000" ]; then # We have silence if [ -f "/tmp/silencemarker" ] ; then - # There was silence last time we checked, so play the tone. - # Even though there may have been some sounds played since the previous - # observation, let's play it safe. - echo 'Play inaudible tone (40 Hz for 1 sec)' - play -nq synth 1 sine 40 fade 0.2 0 + timerMins=10m else touch /tmp/silencemarker + timerMins=4m fi + # Play the tone. + # Even though there may have been some sounds played since the previous + # observation, let's play it safe. + echo 'Play inaudible tone (40 Hz for 1 sec)' + play -nq synth 1 sine 40 fade 0.2 0 else # Sound was detected so remove the marker file if it is there if [ -f "/tmp/silencemarker" ] ; then @@ -42,9 +44,9 @@ else fi fi -# Set a 10 minute timer. Accuracy is 'per-minute' so the interval may be +# Set a timer. Accuracy is 'per-minute' so the interval may be # as long as 11 minutes. This is ok for Creative Gigaworks; they turn off after 11+mins. -systemd-run --user --on-active=10m /usr/local/bin/speakerSqueaker.sh +systemd-run --user --on-active=${timerMins} /usr/local/bin/speakerSqueaker.sh #TODO: possibly allow actual turn off if no sound has been heard for a 'long' time #TODO: Measure actual power consumption to see how futile erp actually is |
