add mail-notify script
This commit is contained in:
commit
b40eb1e6b0
1 changed files with 36 additions and 0 deletions
36
mail-notify.bash
Executable file
36
mail-notify.bash
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
MAILDIRNEW="$HOME/Downloads/Mail/*/INBOX/new/"
|
||||||
|
TMPFILE="/tmp/mail-notify.stat"
|
||||||
|
|
||||||
|
|
||||||
|
# run mail sync
|
||||||
|
$@
|
||||||
|
|
||||||
|
|
||||||
|
# Get modification date
|
||||||
|
MODOLD=0
|
||||||
|
if [ -f "$TMPFILE" ]; then
|
||||||
|
MODOLD="$(cat $TMPFILE)"
|
||||||
|
fi
|
||||||
|
MODNEW="$(find $MAILDIRNEW -type d -printf '%T@\n' | sort -n | tail -1 | cut -d "." -f 1)"
|
||||||
|
if [ $MODNEW -le $MODOLD ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "$MODNEW" > "$TMPFILE"
|
||||||
|
|
||||||
|
|
||||||
|
# Count new mails
|
||||||
|
MAILNEW="$(find $MAILDIRNEW -type f | wc -l)"
|
||||||
|
|
||||||
|
# Notify
|
||||||
|
if [ $MAILNEW -gt 0 ]
|
||||||
|
then
|
||||||
|
if [ $MAILNEW -gt 1 ]; then
|
||||||
|
notify-send -a "Mail" -c "email.arrived" -i "mail-message-new" "Neue E‑Mails" "$MAILNEW neue E‑Mails sind eingetroffen!"
|
||||||
|
else
|
||||||
|
notify-send -a "Mail" -c "email.arrived" -i "mail-message-new" "Neue E‑Mails" "$MAILNEW neue E‑Mail ist eingetroffen!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue