If you are using mutt and fetchmail, but still want to have desktop notifications when new mail arrives, here is a solution.

Script requires notify-send. In order to use it, you have to install libnotify binaries. On Debian just run:

# apt-get install libnotify-bin

fetchmail-notify

I hope script comments are understandable for everyone.

#!/bin/sh

# Check first, if there is an internet connection.
# If you don't have internet connection, obviously do nothing.
CONNECTED=`/sbin/route -n | grep -c '^0\.0\.0\.0'`
if [ ! $CONNECTED -eq 1 ]; then
    exit
fi

# 1. Save logs and errors to apropriate files.
# 2. You have to pipe errors to file or /dev/null in order to avoid these
#    nasty mail notifications sent by cron.
fetchmail -v >> ~/Maildir/fetchmail.log 2>>~/Maildir/fetchmail.err

# As `man fetchmail` says, 0 is equal to:
# "One or more messages were successfully retrieved"
if [ "$?" =  "0" ]; then

# Show notification on first active desktop,
# hide it after 10 seconds,
# use custom icon
# as notification title set: 'E-mail'
# as nofitication text set: 'Nowa poczta w skrzynce' (New mail in inbox)
    DISPLAY=:0.0 notify-send --expire-time=10000 --icon=/path/to/icon/new-mail.png 'E-mail' 'Nowa poczta w skrzynce'
fi

Cron

Run:

crontab -e

And enter following:

*/10 * * * * /path/to/your/fetchmail-notify-script

Outro

Steps above will allow you to check your mail every 10 minutes. If there was at least one mail fetched, there should be a notification on your desktop.