Skip to content

Instantly share code, notes, and snippets.

@benmills
Created January 15, 2013 15:50
Show Gist options
  • Save benmills/4539617 to your computer and use it in GitHub Desktop.
Save benmills/4539617 to your computer and use it in GitHub Desktop.
Check for new mail and unread mail count with fetchmail
#!/bin/bash
if [ -z $2 ]; then
count_file=/tmp/unread_count
else
count_file=$2
fi
/usr/bin/fetchmail --check -u $1 2>/dev/null | while read line; do
total=$(echo $line | cut -d" " -f1)
read=$(echo $line | cut -d" " -f3 | sed 's/(//')
unread=$(echo "$total - $read" | bc)
echo $unread > $count_file
notify-send $1 "new mail"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment