#!/bin/sh for maildir; do printf 'monitoring: %s\n' "$maildir" set -- "$@" "${maildir}/new" shift done inotifywait --monitor --event create --event moved_to "$@" | while read -r dir _action file; do grep '^\(Subject\|From\|To\): .*$' <"${dir}${file}" | sed -e 's//\>\;/g' | notify-send -a maildir-notify -c email.arrived -i mail-unread \ 'You have new mail' "$(cat -)" done