From 35ddd7d71b7a8676f74c2627f2aa3bb7455a7c95 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 4 May 2018 13:10:21 -0700 Subject: [PATCH] update of mailsync script with dunst support --- .gitignore | 1 + etc/email.gif | Bin 0 -> 7545 bytes etc/mailsync.sh | 37 +++++++++++++++---------------------- 3 files changed, 16 insertions(+), 22 deletions(-) create mode 100644 etc/email.gif diff --git a/.gitignore b/.gitignore index 77ab643..a14de95 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ accounts/ personal.muttrc thunderbird/ autoconf/log +etc/mailsynclastrun diff --git a/etc/email.gif b/etc/email.gif new file mode 100644 index 0000000000000000000000000000000000000000..1ed63cfd7db8f606ef6645fce61e126c36f3ea73 GIT binary patch literal 7545 zcmb_=_dgVlJU=sj6|rj3PmTf$B`{{w8)mdLb5M=ud`)!#^J0E5kgjG z>6B5u#aI(*f)kfqwNS|X~^1ohSo*=d0+ z*5xTPz_yt4QH{`P#`p?T$tnxkW|zw?4pML3&h*+K2kjAkR_wiYm>&C6!;Wx zrHAaR-fUY>z#G1ZH9!9CVBR%Sv1F&)1iJrmOzUP}@vUXij)E6sA8IefPu5yFYWZ_jC0& zvh;uE8}1jI?3Y{bms+eB+x5SGI{3Weqc;e~Cn z#T{|wT@mG7DHUC>8s1e_l;>rpF-oE)sY&~t;cKli@7u}_dg2b~uMQa5Yu%Xxy>Dj* zTc^6q4#o=i-&s&A^m5x&q#&Y4u$FzSnMMi!ICV|C-qs;z2?o%5E)ujE~rZ#V<{ zWd!T*H5%;MY?FDLO2@+$E_m#h)mvp{cwB0YF}wWWLzsbV#n(-F=T^7SxuIr^67@ro ze%$rTR>b=L_%8;Pso(Bcd~SVG*l%d1c&~ufm(0t-Rc759zie=GC)GZBZSeJQ$J=?A z(JVDjmuT2*OYMBC=<3<11W#oz$AQFNMp~V9Gnq2wnHT(sUqtwqtIuke*J+Li z^D1uDk7HJfI9@uck{25tewG}{m^WCQ?CnyRKlfI8q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b-4N({D6TgQ06rBB>@kg2j9 zqd4}3-}MClao{#y(246p6%nMzXLT+=f}fe!i7~ zIQwF4#1>WDV>u4Z(qzsX{o%L15;>O^D_N@f{B};sbdLz}w5*ky+UDnul`ZRY`~$^L19s?A!8Shz zMT3RCtzGKa?gNdxb<*!zxYJ)-+WcNkEsSxYEKi9qPV>h)yB_}-dN`o&v+!)=@8P1z zhVZXR+fZkIfCjJ_^WKtPBt2p4z?Nj}QW|kIFV1!K*XNdvtG?z>b0v;Pd!=%Z2W{Qy z(zmrZ>Ac2D<4%6Rfvn!&6F>(#zd5=5wEu4CncUxivTF;Jv5+rndBBr**sJDB_|Pvm zb8#m)sNwN4S4oCFyF3`WQP;zjPo6&#a%=mMITkLZw9G=OXmQskg`azz55H-yZ1#c7 zSMW>w44|9inj16f(aO^19{`N+3N`dkoCD7di!1y2wS2d1R(P||(FJM>Fu4|I&Z&=c z-Z~EDx&{%S`NK@T8eI@-8sI2YuA+OXSw5lY#XY3w%=HP4WWM~(@G}5z=(Xc+UI&O1 z`@huK+fG^uPa4IAho}3;8ODi9srSUaW>QNwwJ$LD8f^o_zVHIGuwlhJ2hdE zh1wDlH)9OOtMA;+-PDn}FvDT>d?GFMD+Fhxsc)wck^T-MDWOXa<+O5~;7Wh%tng|! zM&8VYuh7ECxo9hOi25?HjV6xUBt%^u$>$n^xT+M2X}G5~C=>_?N;=NcuR7hy`5rC> z&;!OAQ!i5d!tK=$-rgReh2{PWaU-x@A%^jP$m7s;)8cC*Mk;^E=ZbLCvE)Mo)cy|$ COTBgg literal 0 HcmV?d00001 diff --git a/etc/mailsync.sh b/etc/mailsync.sh index 205a1c8..ca72e39 100755 --- a/etc/mailsync.sh +++ b/etc/mailsync.sh @@ -7,39 +7,32 @@ # # I have this run as a cronjob every 5 minutes. -# Check for internet connection. Exit script if none. (timeout in mac is `-t`) +export DISPLAY=:0.0 + +# Checks for internet connection and set notification script. +# Settings are different for MacOS (Darwin) systems. if [ "$(uname)" == "Darwin" ] then ping -q -t 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit + notify() { osascript -e "display notification \"$2 in $1\" with title \"Youve got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} else ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit + notify() { pgrep -x dunst && notify-send -i ~/.config/mutt/etc/email.gif "$2 new mail(s) in \`$1\` account." ;} fi -# Get current number of new mail, then begin sync. -ori=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l) +# Run offlineimap. You can feed this script different settings. offlineimap -o "$@" -# Recount new mail. -new=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l) - -# If new mail has grown, play a notification. -if [ "$new" -gt "$ori" ]; then - mpv --quiet ~/.config/mutt/etc/notify.opus -fi - +# Check all accounts/mailboxes for new mail. Notify if there is new content. for account in $(ls ~/.mail) do - for mailbox in $(ls ~/.mail/$account/) - do - #List unread messages newer than last mailsync and count them - newcount=$(find ~/.mail/$account/$mailbox/new/ -type f -newer ~/.config/mutt/etc/mailsynclastrun 2> /dev/null | wc -l) - #Pop a Mac style notification with the count for that mailbox - if [ "$(uname)" == "Darwin" -a "$newcount" -gt "0" ] - then - osascript -e "display notification \"$newcount in $mailbox\" with title \"Youve got Mail\" subtitle \"Account: $account\"" - sleep 2 - fi - done + #List unread messages newer than last mailsync and count them + newcount=$(find ~/.mail/$account/INBOX/new/ -type f -newer ~/.config/mutt/etc/mailsynclastrun 2> /dev/null | wc -l) + if [ "$newcount" -gt "0" ] + then + notify "$account" "$newcount" & disown + mpv --quiet ~/.config/mutt/etc/notify.opus + fi done #Create a touch file that indicates the time of the last run of mailsync