This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/scripts/checkmail

34 lines
593 B
Bash
Executable File

#!/bin/sh
set -e
if test -z "$SWAYSOCK" && pidof gnome-shell > /dev/null
then
exit 0
fi
die() {
test "$?" = 0 ||
notify-send "Failed to sync mail" "try unlocking your gpg key"
}
# trap die EXIT
{%@@ for name in mail | reverse @@%}
mkdir -p "$HOME/.local/share/mail/{{@@ name @@}}/"
{%@@ endfor @@%}
if test "$1" = "update" && ! pidof mbsync; then
if ! ping -c3 {{@@ mail.personal.imap @@}} > /dev/null
then
exit 0
fi
mbsync -a
fi
cd "$HOME/.local/share/mail/" >/dev/null
find */INBOX*/new -type f |
wc -l |
sed 's/^0$//'
# vim:ft=sh