#!/bin/bash # Requires https://www.google.com/settings/security/lesssecureapps for gmail. CONFIG_FILE="${BLOCK_INSTANCE}" CONFIG_FILE=${CONFIG_FILE/\~/$HOME} # Config file needs the following settings: #MAIL_USER="user@domain.tld" #MAIL_PASSWORD="secret" if [[ ! -f "${CONFIG_FILE}" ]]; then echo "${CONFIG_FILE}" exit 33 fi source "${CONFIG_FILE}" COUNT=`curl -su $MAIL_USER:$MAIL_PASSWORD https://mail.google.com/mail/feed/atom || echo "unknown number of"` COUNT=`echo "$COUNT" | grep -oPm1 "(?<=)[^<]+" ` if [ "$COUNT" = "0" ]; then echo "" else echo $COUNT fi