myhome/.local/bin/mailsync
2020-05-09 13:43:39 +02:00

27 lines
904 B
Bash
Executable File

#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.
# Checks for internet connection and set notification script.
ping -q -c 1 1.1.1.1 > /dev/null || exit
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."
export DISPLAY=:0.0
# IKONKA SYNC ##echo " 🔃" > /tmp/imapsyncicon_$USER
pkill -RTMIN+12 i3blocks
# Run mbsync. You can feed this script different settings.
mbsync -a
# IKONKA SYNC #rm -f /tmp/imapsyncicon_$USER
pkill -RTMIN+12 i3blocks
RESULT=$(echo "$(du -a ~/.mailbox/*/inbox/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)")
#if [ -z $RESULT ]; then
# echo ""
#else
# notify-send "mutt-wizard" "📬 new mail(s)"
#fi
#Create a touch file that indicates the time of the last run of mailsync
touch "$HOME/.mutt/.mailsynclastrun"