|
|
@@ -59,15 +59,16 @@ syncandnotify() { |
|
|
|
if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi |
|
|
|
new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null) |
|
|
|
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) |
|
|
|
if [ "$newcount" -gt "0" ]; then |
|
|
|
notify "$acc" "$newcount" & |
|
|
|
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 |
|
|
|
fi |
|
|
|
case 1 in |
|
|
|
$((newcount > 5)) ) notify "$acc" "$newcount" ;; |
|
|
|
$((newcount > 0)) ) notify "$acc" "$newcount" |
|
|
|
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 ;; |
|
|
|
esac |
|
|
|
} |
|
|
|
|
|
|
|
# Sync accounts passed as argument or all. |
|
|
|