#!/bin/bash export DISPLAY=:0 CHECK_FILE="/home/pavel/Mail/.last_check" QUERY="tag:unread" ALL_QUERY="tag:unread" if [ -f "$CHECK_FILE" ]; then DATE=$(cat "$CHECK_FILE") QUERY="$QUERY and date:@$DATE.." fi notmuch new NEW_UNREAD=$(notmuch count "$QUERY") ALL_UNREAD=$(notmuch count "$ALL_QUERY") if [ $NEW_UNREAD -gt 0 ]; then MAIN_UNREAD=$(notmuch count "tag:unread AND tag:main") PROGIN_UNREAD=$(notmuch count "tag:unread AND tag:progin") notify-send "New Mail" "$NEW_UNREAD new messages\n$MAIN_UNREAD thexcloud@gmail.com\n$PROGIN_UNREAD progin6304@gmail.com\n$ALL_UNREAD total" fi echo "$(date +%s)" > $CHECK_FILE