* **histogram.sh**: example using histogram.pl to draw realtime equalizer
* **sleepmon.sh**: Generates frequency on soundcard output and detects it on input
* Can be used to detect and log motion using soundcard and PIR sensor or NC switch
+ * **sleepplot.sh*: Generates gnuplot graph from sleeplog
* TODO
* Guitar tuner
* Send me more...
level="$(echo "$line" | cut -f 2)"
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 && {
echo -ne "\t$level After $after secs";
}
echo;
+ ./sleepplot.sh "$out" &>/dev/null;
lastdate="$date";
done | tee "$out"
kill $!
--- /dev/null
+#!/bin/bash
+
+test -z "$1" && {
+ echo "Usage: $0 sleeplog.txt"
+ exit 23
+}
+
+size="$(tail -n 1 "$1" | cut -d . -f 1)"
+test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
+size="$(( 200 + ($size * 2) ))"
+
+gnuplot << EOF
+set output "$1.png"
+set terminal png size $size,200
+
+set title "Sleep motions"
+set xlabel "time"
+set ylabel "motion"
+
+set yrange [-0.5:1.5]
+
+set xdata time
+set timefmt "%s"
+#set format x "%H:%M:%S"
+
+#set y2tics 300
+#set ytics 5
+
+set grid
+
+#set pointsize 0.5
+plot "$1" using 2:5 with histeps;
+
+EOF
+
+
+
+