mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-02-21 10:27:22 +08:00
32 lines
491 B
Bash
32 lines
491 B
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
lastmsg=""
|
|
path="/run/shm/msg.html"
|
|
|
|
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"* ) refresh ;;
|
|
"delete_self" ) echo "c: vnc" ;;
|
|
esac
|
|
done
|