diff options
Diffstat (limited to 'scripts/mailnotify.sh')
-rwxr-xr-x | scripts/mailnotify.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/mailnotify.sh b/scripts/mailnotify.sh new file mode 100755 index 0000000..0c22e57 --- /dev/null +++ b/scripts/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 |