From 78db7d43845d3ea276b8028bec6d67b5a5641a1b Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Wed, 21 Sep 2016 20:01:28 +0200 Subject: =?UTF-8?q?Ajout=20de=20la=20conf=20de=20vim=20+=20mise=20=C3=A0?= =?UTF-8?q?=20jour=20de=20la=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i3/blocks/mail | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 i3/blocks/mail (limited to 'i3/blocks/mail') diff --git a/i3/blocks/mail b/i3/blocks/mail new file mode 100755 index 0000000..66b1d0a --- /dev/null +++ b/i3/blocks/mail @@ -0,0 +1,59 @@ +#!/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_SERVER="imap.domain.tld:993" +#MAIL_USER="user@domain.tld" +#MAIL_PASSWORD="secret" +#MAIL_FOLDER="INBOX" + +if [[ ! -f "${CONFIG_FILE}" ]]; then + echo "${CONFIG_FILE}" + exit 33 +fi + +source "${CONFIG_FILE}" + +MAIN_DOMAIN=$(expr match "${MAIL_SERVER}" '.*\.\(.*\..*\)' | awk -F ':' '{print $1}') + +# Add https so xdg knows that it's a website +if [[ "${MAIN_DOMAIN}" != http* ]]; then + MAIN_DOMAIN="https://${MAIN_DOMAIN}" +fi + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xdg-open "${MAIN_DOMAIN}" +fi + +MAIL_FILE="/tmp/.mail" +URGENT_VALUE="100" + +GET_UNREAD=$(cat< "${MAIL_FILE}" 2>/dev/null +UNREAD_COUNT=$(cat "${MAIL_FILE}" | grep -i "UNSEEN" | grep -oE "[0-9]*" | head -n 1) + +# For security reasons +rm "${MAIL_FILE}" + +if [[ "${UNREAD_COUNT}" = "" ]]; then + exit +fi + +echo "${UNREAD_COUNT}" +echo "${UNREAD_COUNT}" +echo "" + +if [[ "${UNREAD_COUNT}" -ge URGENT_VALUE ]]; then + exit 33 +fi \ No newline at end of file -- cgit v1.2.1