aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mbsync/.local/bin/maildir-notify
blob: 4250bfed961edad08a3a29b75b546c4bfa74d21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/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/</\&lt\;/g' -e 's/>/\&gt\;/g' |
			notify-send -a maildir-notify -c email.arrived -i mail-unread \
				'You have new mail' "$(cat -)"
	done