aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-11-06 17:10:42 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2019-11-06 17:10:42 +0100
commit3b90fdadb737e587a5d184e5ec66ee1d68aa5764 (patch)
treee410edfbf06ccae0ee8c4d077dd3595f1f572248
parent42b4dd8a0319a8828e6aea97b847ed554d22f15e (diff)
downloadscripts-3b90fdadb737e587a5d184e5ec66ee1d68aa5764.tar.gz
scripts-3b90fdadb737e587a5d184e5ec66ee1d68aa5764.zip
Updated and generalized script for i3blocks mail module.
-rwxr-xr-xi3blocks/i3mailbox.sh25
1 files 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% }"