[mail] cleanup: notify only the maount of mails
no need to get loads of infos, just to know you get a mail
This commit is contained in:
parent
1249c0099b
commit
9b6842e073
@ -32,23 +32,14 @@ export GPG_TTY=$TTY
|
||||
notify() {
|
||||
notify-send "neomutt" " $2 new mail(s) in \`$1\` account."
|
||||
}
|
||||
messageinfo() {
|
||||
notify-send " $from:" "$subject"
|
||||
}
|
||||
|
||||
# Check account for new mail. Notify if there is new content.
|
||||
syncandnotify() {
|
||||
acc="$(echo "$account" | sed "s/.*\///")"
|
||||
mbsync "$acc"
|
||||
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f -newer "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" | grep -iv "trash" 2>/dev/null)"
|
||||
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" 2>/dev/null)"
|
||||
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
|
||||
if [ "$newcount" -gt "0" ]; then
|
||||
for file in $new; do
|
||||
# Extract subject and sender from mail.
|
||||
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
|
||||
subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
|
||||
messageinfo &
|
||||
done
|
||||
notify "$acc" "$newcount" &
|
||||
[ -n "$(pidof dwmblocks)" ] && kill -40 $(pidof dwmblocks)
|
||||
fi
|
||||
|
Reference in New Issue
Block a user