diff options
author | Yann Herklotz <git@yannherklotz.com> | 2022-11-19 21:11:35 +0000 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2022-11-19 21:11:35 +0000 |
commit | c6267bd2101d8e381d76317c36a8879519dcb949 (patch) | |
tree | a314503f0bac03202cf41b902b47de1c7857b19f /scripts/.local/bin/mailnotify.sh | |
parent | 2ece7032558cd0be673d65237a01c5e6ffe625f1 (diff) | |
download | dotfiles-c6267bd2101d8e381d76317c36a8879519dcb949.tar.gz dotfiles-c6267bd2101d8e381d76317c36a8879519dcb949.zip |
Also allow for custom scripts to be installed by GNU Stow
Diffstat (limited to 'scripts/.local/bin/mailnotify.sh')
-rwxr-xr-x | scripts/.local/bin/mailnotify.sh | 13 |
1 files changed, 13 insertions, 0 deletions
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 |