28 lines
512 B
Plaintext
28 lines
512 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
READER=human-activity-sensor
|
||
|
LAST_SEEN_FILE=/var/tmp/human_last_seen
|
||
|
LAST_CHECKED_FILE=/var/tmp/human_last_checked
|
||
|
|
||
|
echo "Human Activity Daemon"
|
||
|
echo ""
|
||
|
echo "Last seen file: $LAST_SEEN_FILE"
|
||
|
echo "Last checked file: $LAST_CHECKED_FILE"
|
||
|
echo ""
|
||
|
echo "Values stream:"
|
||
|
|
||
|
LAST_VAL=-1
|
||
|
while [[ true ]]; do
|
||
|
VAL=`$READER`
|
||
|
touch $LAST_CHECKED_FILE
|
||
|
if [[ $VAL == "1" ]]; then
|
||
|
touch $LAST_SEEN_FILE
|
||
|
fi
|
||
|
if [[ $LAST_VAL != $VAL ]]; then
|
||
|
echo "[`date "+%F %T"`] $VAL"
|
||
|
LAST_VAL=$VAL
|
||
|
fi
|
||
|
sleep 1
|
||
|
done
|
||
|
|