From 3b90fdadb737e587a5d184e5ec66ee1d68aa5764 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Wed, 6 Nov 2019 17:10:42 +0100 Subject: Updated and generalized script for i3blocks mail module. --- i3blocks/i3mailbox.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/i3blocks/i3mailbox.sh b/i3blocks/i3mailbox.sh index 70343c8..213eb6a 100755 --- a/i3blocks/i3mailbox.sh +++ b/i3blocks/i3mailbox.sh @@ -1,6 +1,9 @@ #!/bin/sh -# i3blocks mail module. +# i3mailbox.sh (i3blocks mail module) +# +# Usage: i3mailbox.sh +# # Displays number of unread mail and an loading icon if updating. # When clicked, brings up `neomutt`. @@ -13,11 +16,21 @@ case $BLOCK_BUTTON in - Middle click syncs mail" ;; esac +gmailInbox="$CONFIG_FOLDER_GMAIL_INBOX" +unioviInbox="$CONFIG_FOLDER_UNIOVI_INBOX" +output="" syncIcon="" [ -n "$(pgrep mbsync)" ] && syncIcon="🔃" -gmailN="$(du -a ~/.mail/gmail/INBOX/new/* 2>/dev/null | sed -n '$=')" -[ "$gmailN" ] || gmailN="0" -unioviN="$(du -a ~/.mail/uniovi/INBOX/new/* 2>/dev/null | sed -n '$=')" -[ "$unioviN" ] || unioviN="0" +output="$output$syncIcon" + +if [ -n "$gmailInbox" ]; then + gmailN="$(ls "$gmailInbox"/* 2>/dev/null | wc -l)" + output="$output Gmail: $gmailN " +fi +if [ -n "$unioviInbox" ]; then + unioviN="$(ls "$unioviInbox"/* 2>/dev/null | wc -l)" + output="$output Uniovi: $unioviN " +fi + #echo "$(cat /tmp/imapsyncicon) Gmail: $gmailN uniovi: $unioviN" -echo "$syncIcon Gmail: $gmailN uniovi: $unioviN" +echo "${output% }" -- cgit v1.2.1