summaryrefslogtreecommitdiff
path: root/sync-mail
blob: c5345a036427f302a61a7cfdf16772d099616095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/zsh -x

$(which imapfilter) -c $HOME/.imapfilter/private.lua 2>/dev/null
$(which imapfilter) -c $HOME/.imapfilter/work.lua 2>/dev/null

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've got mail."
  fi
fi