diff options
author | Yann Herklotz <git@yannherklotz.com> | 2019-11-07 12:39:12 +0000 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2019-11-07 12:39:12 +0000 |
commit | 3fed8bf7b2915d2d00b830f5103a4962a29be4c7 (patch) | |
tree | 41e64a9f70fcaa57bf55d95a9928edbd2c57c186 /scripts/mailnotify.sh | |
parent | acedbb6a814796ee5b7e8f4e355b1757443dae22 (diff) | |
download | dotfiles-3fed8bf7b2915d2d00b830f5103a4962a29be4c7.tar.gz dotfiles-3fed8bf7b2915d2d00b830f5103a4962a29be4c7.zip |
Add scripts and services
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 |