From 637225311a825d25f84d687fa873c3966a8cbb3f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 3 Nov 2016 18:45:53 +0100 Subject: [PATCH] panel/lemons: mail.sh now considers all my accounts --- os/arch/.config/panel/lemons/mail.sh | 33 +++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/os/arch/.config/panel/lemons/mail.sh b/os/arch/.config/panel/lemons/mail.sh index 587e16ad..0803be7f 100755 --- a/os/arch/.config/panel/lemons/mail.sh +++ b/os/arch/.config/panel/lemons/mail.sh @@ -2,22 +2,19 @@ [ -f ~/.secrets/accounts.sh ] && . ~/.secrets/accounts.sh || exit -feed=$(curl -u "${MAIL_USER}:${MAIL_PASS}" --silent https://mail.google.com/mail/feed/atom) -con=$(echo $feed | grep -c "") -num=$(echo $feed | grep -o "" | wc -l) +get-mail() { + local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom) + if [ "$(echo $feed | grep -c "")" -eq 1 ] + then + echo $feed | grep -o "" | wc -l + else + >&2 echo "mail.sh: error with $1" + echo 0 + fi +} -if [ "$con" -eq 1 ] -then - # if [ "$num" -gt 0 ]; then - # oldnum=0 - # [ -f /tmp/newmail ] && oldnum=$(cat /tmp/newmail) - # echo "$num" > /tmp/newmail - # if [ "$num" -ne "$oldnum" ] - # then - # notify-send 'New email' - # fi - # fi - echo "M$num" -else - echo "M!" -fi +a=$(get-mail "${MAIL1[USER]}" "${MAIL1[PASS]}") +b=$(get-mail "${MAIL2[USER]}" "${MAIL2[PASS]}") +c=$(get-mail "${MAIL3[USER]}" "${MAIL3[PASS]}") + +echo M$(( $a + $b + $c ))