Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
/etc/rc.local - RPiCamWebInterface Annotation %a
# Description: use /etc/rc.local to initiate a loop-script which writes to the RPiCamWebInterface Annotation (%a) file.
# servicectl services/timers may not run a 1 second timer at anyhting like 1 second intervals
# Whereas a script running a simple loop will. Particualrly if the loops timing accounts for minor variations.
# you can activate this either:
# 1) by manually adding the path/filename of the script to /etc/rc.local
# or
# 2) like I do: (as part of another script that loops through all of my pizerocams)
scp -q \
/home/user/documents/scripts/raspberry/home/pi/ \
msg1="activating:" ;msg2="user annotation %a"; f_msg
ssh -q $targetHost bash <<'EOF'
[[ -f /etc/rc.local && -z $(grep -o '/home/pi/' /etc/rc.local) ]] && sudo sed -Ei 's/exit\ 0/\/home\/pi\/ \# services do not run evenly at actual second precision repeats so just fork a looping script\n\nexit\ 0/' /etc/rc.local
# for use with RPiWebCamInterface %a
# initiate this script via /etc/rc.local
# or run it as root
# if you run it non-root values print to console but RPCWI will not use it as annotiation (%a)
while :; do # services do not run evenly at actual second precision repeats, so just fork a looping script
startTime=$(date +%s.%3N)
degC="$(echo "scale=1;$(cat /sys/class/thermal/thermal_zone0/temp)/1000"|bc|sed -E 's/^\./0\./')C"
annotation="$HOSTNAME ${degC}"
# last="$(cat /dev/shm/mjpeg/user_annotate.txt|sed -E 's/.*(.)/\1/')"
# [[ "<" == "$last" || "C" == "$last" ]] && annotation+=" >" || annotation+=" <"
echo -ne "$annotation"
[[ "$EUID" -eq 0 ]] && echo -ne "$annotation" >/dev/shm/mjpeg/user_annotate.txt
sleep $(echo "scale=3; 1.000 - ( $(date +%s.%3N) - $startTime )"|bc)s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment