#! /usr/bin/env bash # Necessary to see the notification export DISPLAY=:0 # Get all emails mbsync -a new_mails=$(find $HOME/.mail -path '*/new/*' -type f) subjects=$(cat $(echo -e ${new_mails/'\n'/' '}) | grep "^Subject: " | sed "s/^Subject: //g") if [[ ! -z ${new_mails} ]]; then /usr/bin/notify-send -t 3 "New mail(s)!" "${subjects}" fi echo "Email last checked on $(date)".