@@ -33,7 +33,6 @@ export GPG_TTY="$(tty)" | |||||
case "$(uname)" in | case "$(uname)" in | ||||
Darwin) | Darwin) | ||||
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} | notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} | ||||
messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;} | |||||
;; | ;; | ||||
*) | *) | ||||
case "$(readlink -f /sbin/init)" in | case "$(readlink -f /sbin/init)" in | ||||
@@ -46,10 +45,6 @@ case "$(uname)" in | |||||
export DISPLAY=$x | export DISPLAY=$x | ||||
notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." | notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." | ||||
done ;} | done ;} | ||||
messageinfo() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do | |||||
export DISPLAY=$x | |||||
notify-send --app-name="mutt-wizard" "📧$from:" "$subject" | |||||
done ;} | |||||
;; | ;; | ||||
esac | esac | ||||
@@ -67,13 +62,7 @@ syncandnotify() { | |||||
-type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null) | -type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null) | ||||
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) | newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) | ||||
case 1 in | case 1 in | ||||
$((newcount > 5)) ) notify "$acc" "$newcount" ;; | |||||
$((newcount > 0)) ) 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 ;; | |||||
$((newcount > 0)) ) notify "$acc" "$newcount" ;; | |||||
esac | esac | ||||
} | } | ||||
@@ -49,6 +49,7 @@ canaglie.net,mail.autistici.org,993,smtp.autistici.org,465 | |||||
canaglie.org,mail.autistici.org,993,smtp.autistici.org,465 | canaglie.org,mail.autistici.org,993,smtp.autistici.org,465 | ||||
carleton.ca,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 | carleton.ca,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 | ||||
cash4u.com,imap.mail.com,993,smtp.mail.com,587 | cash4u.com,imap.mail.com,993,smtp.mail.com,587 | ||||
cedars.xyz,imap.cedars.xyz,993,smtp.cedars.xyz,465 | |||||
ceng.metu.edu.tr,imap.ceng.metu.edu.tr,993,mailhost.ceng.metu.edu.tr,587 | ceng.metu.edu.tr,imap.ceng.metu.edu.tr,993,mailhost.ceng.metu.edu.tr,587 | ||||
cheerful.com,imap.mail.com,993,smtp.mail.com,587 | cheerful.com,imap.mail.com,993,smtp.mail.com,587 | ||||
chef.net,imap.mail.com,993,smtp.mail.com,587 | chef.net,imap.mail.com,993,smtp.mail.com,587 | ||||