announcement-box/toolkit/human-activity-daemon

28 lines
512 B
Plaintext
Raw Permalink Normal View History

2020-12-17 19:08:59 +00:00
#!/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