#!/bin/zsh -x if [[ $(uname) == "Darwin" ]]; then export PATH=/Users/$(whoami)/.local/bin:$PATH fi if [[ $(uname) == "Linux" ]]; then export PATH=/home/$(whoami)/.local/bin:$PATH fi $(which imapfilter) -c $HOME/.imapfilter/private.lua 2>/dev/null if [[ ! -f ~/.holiday ]]; then $(which imapfilter) -c $HOME/.imapfilter/work.lua 2>/dev/null fi case `date +"%a"` in Sat|Sun) $(which mbsync) -q private ;; *) if [[ -f ~/.holiday ]]; then $(which mbsync) -q private else $(which mbsync) -q -a fi ;; esac new="$(find $HOME/.mail/*/inbox/new/ -type f | wc -l)" old="$(find $HOME/.mail/*/inbox/cur/ -type f | wc -l)" if [ $new -gt 0 ] then if [[ $(uname) == "Linux" ]]; then export DISPLAY=:0 export XAUTHORITY=$HOME/.Xauthority; /usr/bin/notify-send "You got mail ($new)." fi if [[ $(uname) == "Darwin" ]]; then osascript -e "display notification \"$new new mails.\" with title \"You got mail.\"" fi fi