elenapan/config/polybar/mails
elena dd677bde98 massive config and scripts update
Former-commit-id: 46c2bf7d26
Former-commit-id: ec0b4e689f3f8e97d837848929a1a6a9e45f779b
Former-commit-id: 19f055447f5fd666a270a51cf98b05d70716e826
2018-01-21 14:19:40 +02:00

34 lines
811 B
Bash
Executable file

#!/bin/sh
# This program will automatically search your mails.
# And print number of new messages.
# Require another prog for doing this, offlineimap, msmtp or isync.
gmaildir=/home/user/.mails/Gmail/\[Gmail\].All\ Mail/new
prog=/usr/bin/offlineimap
count=0
log=/tmp/mails.log
if [ -x $prog ] ; then
$prog 2>/dev/null &
wait
if [ $? = 0 ] ; then
echo "$(date) - $prog success" >> $log
elif [ $? = 1 ] ; then
echo "$(date) - $prog has fail" >> $log
else
echo "$(date) - unknown prob" >> $log
fi
fi
if [[ ! -d ${gmaildir} ]] ; then
echo "$(date) - $gmaildir does not exist" >> $log
elif [[ ! -n $(ls "${gmaildir}") ]] ; then
echo "$(date) - $gmaildir no new mail found" >> $log
else
count=$(ls -1 "${gmaildir}" | wc -l)
fi
echo "${count}"