From 46acb72dd7c64fd894522cf6ea1a51005771623c Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sat, 22 Aug 2020 16:59:56 -0500 Subject: [PATCH] Kill in-progress notification hooks if the notif dir is empty --- scripts/notifications/sxmo_notificationmonitor.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/notifications/sxmo_notificationmonitor.sh b/scripts/notifications/sxmo_notificationmonitor.sh index 11d2a36..42fe130 100755 --- a/scripts/notifications/sxmo_notificationmonitor.sh +++ b/scripts/notifications/sxmo_notificationmonitor.sh @@ -1,6 +1,7 @@ #!/usr/bin/env sh trap gracefulexit INT TERM NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications +NOTIFHOOKPIDS="" gracefulexit() { echo "Gracefully exiting $0" @@ -32,6 +33,7 @@ handlenewnotiffile(){ rm -f "$NOTIFFILE" else notificationhook & + NOTIFHOOKPIDS="$NOTIFHOOKPIDS $!" NOTIFACTION="$(awk NR==1 "$NOTIFFILE")" NOTIFWATCHFILE="$(awk NR==2 "$NOTIFFILE")" NOTIFMSG="$(tail -n+3 "$NOTIFFILE" | cut -c1-70)" @@ -54,7 +56,11 @@ recreateexistingnotifs() { monitorforaddordelnotifs() { while true; do - [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -lt 1 ] && sxmo_setpineled green 0 + if [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -lt 1 ]; then + sxmo_setpineled green 0 + echo "$NOTIFHOOKPIDS" | tr ' ' '\n' | xargs -IP kill -9 P + NOTIFHOOKPIDS="" + fi inotifywait -e create,attrib,moved_to,delete,delete_self,moved_from "$NOTIFDIR"/ | ( INOTIFYOUTPUT="$(cat)"