fix: Validate status messages (#1077)

This commit is contained in:
Kroese 2025-10-17 12:07:13 +02:00 committed by GitHub
parent dff8abbe1e
commit e1e5f8f91d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,16 +1,31 @@
#!/usr/bin/env bash
set -Eeuo pipefail
lastmsg=""
path="/run/shm/msg.html"
if [ -f "$path" ] && [ -s "$path" ]; then
echo -n "s: " && cat "$path"
fi
refresh() {
[ ! -f "$path" ] && return 0
[ ! -s "$path" ] && return 0
msg=$(< "$path")
msg="${msg%$'\n'}"
[ -z "$msg" ] && return 0
[[ "$msg" == "$lastmsg" ]] && return 0
lastmsg="$msg"
echo "s: $msg"
return 0
}
refresh
inotifywait -m "$path" |
while read -r fp event fn; do
case "${event,,}" in
"modify"* ) echo -n "s: " && cat "$path" ;;
"modify"* ) refresh ;;
"delete_self" ) echo "c: vnc" ;;
esac
done