File size: 491 Bytes
021894c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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