From d947956270b092df10637bb3531441caca698b86 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Tue, 25 Nov 2025 18:47:27 +0400 Subject: feat: new api for scripts --- scripts/daemons/notifd | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/daemons/notifd (limited to 'scripts/daemons/notifd') diff --git a/scripts/daemons/notifd b/scripts/daemons/notifd new file mode 100755 index 0000000..9ad5697 --- /dev/null +++ b/scripts/daemons/notifd @@ -0,0 +1,35 @@ +#!/bin/sh + +. "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 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 -- cgit v1.2.3