summaryrefslogtreecommitdiff
path: root/sync-mail
blob: 406e49ca5ef4054626bd3959b2592f69eafd9fb2 (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
#!/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/personal.lua 2>/dev/null

$(which mbsync) -q personal

new="$(find $HOME/.mail/*/inbox/new/ -type f | wc -l)"

if [ $new -gt 0 ]
then
  $(which notmuch) new
  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