From 2b0f7f425d3c56ca10f246e456df0a6ed04cd652 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 21 Nov 2016 20:52:28 +0100 Subject: [PATCH] added mail notification to bar --- i3/.config/i3/i3blocks.conf | 13 +++++++++++++ i3/.config/i3/i3blocks/gmail | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 i3/.config/i3/i3blocks/gmail diff --git a/i3/.config/i3/i3blocks.conf b/i3/.config/i3/i3blocks.conf index afc4230..20bc95b 100644 --- a/i3/.config/i3/i3blocks.conf +++ b/i3/.config/i3/i3blocks.conf @@ -28,6 +28,19 @@ command=/usr/lib/i3blocks/$BLOCK_NAME separator_block_width=15 markup=none +[mail_gmail] +command=~/.config/i3/i3blocks/gmail +label=G +instance=~/.i3mail/gmail +interval=60 +separator=false + +[mail_andthensome] +command=~/.config/i3/i3blocks/gmail +label=A +instance=~/.i3mail/andthensome +interval=60 + # Music [playerctl] command=~/.config/i3/vendor/i3blocks/blocks/playerctl diff --git a/i3/.config/i3/i3blocks/gmail b/i3/.config/i3/i3blocks/gmail new file mode 100755 index 0000000..ddeabde --- /dev/null +++ b/i3/.config/i3/i3blocks/gmail @@ -0,0 +1,25 @@ +#!/bin/bash + +# Requires https://www.google.com/settings/security/lesssecureapps for gmail. + +CONFIG_FILE="${BLOCK_INSTANCE}" +CONFIG_FILE=${CONFIG_FILE/\~/$HOME} + +# Config file needs the following settings: +#MAIL_USER="user@domain.tld" +#MAIL_PASSWORD="secret" + +if [[ ! -f "${CONFIG_FILE}" ]]; then + echo "${CONFIG_FILE}" + exit 33 +fi + +source "${CONFIG_FILE}" + +COUNT=`curl -su $MAIL_USER:$MAIL_PASSWORD https://mail.google.com/mail/feed/atom || echo "unknown number of"` +COUNT=`echo "$COUNT" | grep -oPm1 "(?<=)[^<]+" ` +if [ "$COUNT" = "0" ]; then + echo "" +else + echo $COUNT +fi