helm/os/arch/.config/panel/lemons/mail

38 lines
819 B
Plaintext
Raw Normal View History

2016-11-02 16:58:47 -07:00
#!/usr/bin/env bash
[ -f ~/.secrets/accounts.sh ] && . ~/.secrets/accounts.sh || exit
2016-11-06 16:40:02 -08:00
. $(dirname $0)/../panel-config
2016-11-02 16:58:47 -07:00
2016-11-06 16:40:02 -08:00
ICON_MAIL=""
get-mail() {
local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom)
if [ "$(echo $feed | grep -c "<fullcount>")" -eq 1 ]
then
echo $feed | grep -o "<entry>" | wc -l
else
>&2 echo "mail.sh: error with $1"
2016-11-06 16:40:02 -08:00
ERROR=!
echo 0
fi
}
2016-11-02 16:58:47 -07:00
a=$(get-mail "${MAIL1[USER]}" "${MAIL1[PASS]}")
b=$(get-mail "${MAIL2[USER]}" "${MAIL2[PASS]}")
c=$(get-mail "${MAIL3[USER]}" "${MAIL3[PASS]}")
2016-11-06 16:40:02 -08:00
num=$(( $a + $b + $c ))
icon="${ICON_MAIL}"
color=${COLOR_FG}
case "$num" in
[1-9]*)
icon="$icon$num"
;;
0) color="${COLOR_DIM}"
;;
esac
[ -n "$ERROR" ] && color=${COLOR_1}
echo "M%{F$color}$icon%{F-}"