Asynchronous ploting should have some locking... keep it simple = disable
[mirrors/Programs.git] / c / goertzel / sleepmon.sh
index 3b975ba06d0c84c9a1913dda205638bef4ac98d2..0d32b65c56f2e7678a52539496d338375d802b5b 100755 (executable)
 # Enjoy your data
 
 
-out=/tmp/sleeplog-"$(date +%F_%r)".txt
+out=/tmp/sleeplog-"$(date +%F_%T)".txt
 speaker-test -t sine &>/dev/null &
+pid_test=$!
 tresh=10
 lastdate=0
 screen=false
 while getopts "s" OPT; do
        test "$OPT" == 's' && screen=true;
 done
-arecord | ./goertzel -n -q -l -t $tresh -d 4 | while read line; do
+echo "Writing to file: $out";
+arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do
        date="$(date +%s)"
        time="$(echo "$line" | cut -f 1)"
        level="$(echo "$line" | cut -f 2)"
-       echo -ne "$time\t$date\t$(date '+%F%t%r')\t"
+       echo -ne "$time\t$date\t$(date '+%F%t%T')\t"
        test "$level" -gt "$tresh" && {
-               echo -n "Nothing detected...";
+               echo -n "Nothing detected...";
                $screen && xset dpms force off || true;
        } || {
-               echo -n "Motion detected!!!!";
+               echo -n "Motion detected!!!!";
                $screen && xset dpms force on;
        }
        test "$lastdate" != 0 && {
@@ -38,7 +40,9 @@ arecord | ./goertzel -n -q -l -t $tresh -d 4 | while read line; do
                echo -ne "\t$level After $after secs";
        }
        echo;
+       ./sleepplot.sh "$out" &>/dev/null
        lastdate="$date";
 done | tee "$out"
-kill $!
+kill $pid_test
+echo
 echo "Your file: $out"
This page took 0.126138 seconds and 4 git commands to generate.