Skip to content

Instantly share code, notes, and snippets.

@putnamhill
Created November 1, 2012 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save putnamhill/3993798 to your computer and use it in GitHub Desktop.
Save putnamhill/3993798 to your computer and use it in GitHub Desktop.
an email notifier that listens for finger connections from the mail server
#/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
@putnamhill
Copy link
Author

To do: Make check for mail apple script only run if Mail app is idle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment