announcement-box/toolkit/human-activity-daemon
2020-12-17 20:09:45 +01:00

28 lines
512 B
Bash
Executable File

#!/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