A Crude Maildir Notification Script

Give me notifications of new email. Needs inotify-tools.

#!/bin/sh

mailbox="$HOME/Mail/fastmail/INBOX/new"

while new=$(inotifywait -q -e moved_to "${mailbox}" | awk '{print $3}'); do
    from=$(awk 'match($0,/^From: (.+)$/,m){print m[1]}' "${mailbox}/${new}")
    subj=$(awk 'match($0,/^Subject: (.+)$/,m){print m[1]}' "${mailbox}/${new}")
    notify-send -i xfce-mail "Email from ${from}" "${subj}"
done