Mail notification for maildir maintained by Offlineimap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# WHAT IS THIS SHIT? | |
# It's a script comprising of shitty regexes that notifies you, | |
# when there has been a change in you mailbox dir. | |
# Works best with offlineimap. | |
# PREREQUISITIES | |
# Depends on inotify-tools and libnotify | |
# THANKS | |
# to Nicolas.Estibals (https://bbs.archlinux.org/viewtopic.php?pid=933429#p933429) | |
# for inspiration. | |
# NOTE | |
# inotifywait output usually looks like /home/user/.mail/myname/INBOX/new/ CREATE 1434095160_4.29513.my-Computer\,U\=13529\,FMD5\=7e33429f656f1e6e9d79b29c3f82c57e\:2\, | |
# SETUP | |
MAILBOX="/home/edison23/.mail" # what's you maildir name | |
TIMOUT="7000" # notification timeout | |
# MAGIC WITH SHITTY REGEXES | |
while true; do | |
# watch for changes in folder | |
NOTIFY=`inotifywait -e create -e moved_to ${MAILBOX}/*/*/new 2> /dev/null` | |
# sed out stuff (folder name and file path) from inotifywait output and create popup | |
FILE=`echo $NOTIFY | sed -r "s/(.*?\/) .*? (.*)/\1\2/"` | |
FOLDER=`echo $NOTIFY | sed -r "s/.*?\/(.*\/.*)\/.*\/ .*/\1/"` | |
notify-send -t $TIMOUT "New mail in $FOLDER" "`grep -m 1 ^From: $FILE`\n`grep -m 1 ^Subject: $FILE`" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment