From c6267bd2101d8e381d76317c36a8879519dcb949 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 19 Nov 2022 21:11:35 +0000 Subject: Also allow for custom scripts to be installed by GNU Stow --- scripts/.local/bin/mailnotify.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 scripts/.local/bin/mailnotify.sh (limited to 'scripts/.local/bin/mailnotify.sh') diff --git a/scripts/.local/bin/mailnotify.sh b/scripts/.local/bin/mailnotify.sh new file mode 100755 index 0000000..0c22e57 --- /dev/null +++ b/scripts/.local/bin/mailnotify.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +mail=${HOME}/.mail/imperial/Inbox/new + +inotifywait -m ${mail} | while read line; do + if [[ $line =~ .*MOVED_TO ]] || [[ $line =~ .*CREATE ]]; then + filename=$(echo "$line" | sed -E 's/[[:space:]]+((MOVED_TO)|(CREATE))[[:space:]]+//') + subject=$(grep '^Subject:' $filename | sed -E 's/^Subject:[[:space:]]+//') + from=$(grep '^From:' $filename | sed -E 's/^From:[[:space:]]+//') + dunstify -i mail-unread "$from +$subject" "" & + fi +done -- cgit