X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fsleepmon.sh;h=87967dd9d86148714cc6776541ff5a7033c1e670;hb=6c5737553eba6afbdba017ca776cf8788c85577f;hp=42bbcad33f37a50fb2c249bd50b67b69835d7fc3;hpb=2fbfcde7b31158edd31950a62904dcc72a3966c3;p=mirrors%2FPrograms.git diff --git a/c/goertzel/sleepmon.sh b/c/goertzel/sleepmon.sh index 42bbcad..87967dd 100755 --- a/c/goertzel/sleepmon.sh +++ b/c/goertzel/sleepmon.sh @@ -13,7 +13,7 @@ # Enjoy your data -out=/tmp/sleeplog-"$(date +%F_%r)".txt +out=/tmp/sleeplog-"$(date +%F_%T)".txt speaker-test -t sine &>/dev/null & tresh=10 lastdate=0 @@ -22,16 +22,16 @@ while getopts "s" OPT; do test "$OPT" == 's' && screen=true; done echo "Writing to file: $out"; -arecord | ./goertzel -n -q -l -t $tresh -d 4 | while read line; do +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 "0 Nothing detected..."; $screen && xset dpms force off || true; } || { - echo -n "Motion detected!!!!"; + echo -n "1 Motion detected!!!!"; $screen && xset dpms force on; } test "$lastdate" != 0 && { @@ -39,7 +39,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 $! +echo echo "Your file: $out"