blob: 3d0e8094f88624e39734e269cd56530cedf5d78c (
plain)
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
33
34
35
36
37
|
#!/bin/sh
# Notification daemon that clears notification text after a given time
. "lib_handle.sh"
FIFO=/tmp/noti.fifo
FILE=/tmp/noti.txt
[ -p "${FIFO}" ] || mkfifo "${FIFO}"
exec 3<"${FIFO}"
exec 4>"${FIFO}"
tpid=""
cancel() {
[ -n "${tpid}" ] && kill "${tpid}" 2>/dev/null
tpid=""
}
while read -r n <&3; do
[ "${n}" = "-1" ] && { cancel; continue; }
case "${n}" in ''|*[!0-9]*) continue ;; esac
cancel
[ "${n}" -gt 0 ] || { :>"${FILE}"; notify_handle reload; continue; }
(
sleep "${n}"
:>"${FILE}"
notify_handle reload
) &
tpid=$!
done
|