Created
November 1, 2012 14:03
-
-
Save putnamhill/3993798 to your computer and use it in GitHub Desktop.
an email notifier that listens for finger connections from the mail server
This file contains hidden or 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/bash | |
# usage: | |
# sudo nohup notifymail 2>&1 >/dev/null | |
# to see if it is already running | |
# ps ax | egrep ' (sh /Users/colet/bin/[n]otifymail)|([n]c -l 79)$' | |
[ $(whoami) != 'root' ] && echo must be root && exit | |
# first clean up any old related processes | |
PIDS=$(ps ax | awk -v me=$$ '/ (sh \/Users\/colet\/bin\/[n]otifymail)|([n]c -l 79)$/{if ($1 != me) {print $1}}') | |
echo found $PIDS still running, I am $$ | |
for PID in $PIDS; do | |
# since we're running this with nohup, we'll need to use the KILL signal (9) | |
echo "ps -p $PID && kill -KILL $PID" | |
ps -p $PID >/dev/null && kill -KILL $PID | |
done | |
#M="checking mail..." | |
#APP=Eudora # yes, I'm still using Eudora. ;) | |
APP=Mail # no, I'm not still using Eudora. :( | |
while :; do | |
MSG=$(nc -l 79 <<< 'User notified') | |
if [ "${MSG:0:13}" = "nm_notifyuser" ]; then | |
#echo "$M" | |
# growlnotify -m "$M" -a $APP | |
# osascript -e "tell application \"$APP\" to connect with checking" | |
echo "osascript -e \"tell application \"$APP\" to check for new mail for account \"llsys.com\"" | |
osascript -e "tell application \"$APP\" to check for new mail for account \"llsys.com\"" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To do: Make check for mail apple script only run if Mail app is idle.