abc693dadc14fb80d070c31efdc75fcbfcd1ec51
commit abc693dadc14fb80d070c31efdc75fcbfcd1ec51
Author: Simon Watson <spw01@protonmail.com>
Date: Fri Nov 5 16:48:46 2021 -0400

Updates to lemonbar/email. Lemonbar needs work

diff --git a/himalaya/.himalayarc b/himalaya/.himalayarc
index 33fa856..3aa47e8 100644
--- a/himalaya/.himalayarc
+++ b/himalaya/.himalayarc
@@ -2,7 +2,7 @@ name = "Simon Watson"
downloads-dir = "~/.mail"
signature = ""
default-page-size = 50
-#watch-cmds = ["mbsync -a"]
+notify-cmd = "notify-send \"New Email\""

[gmail]
default = true
diff --git a/lemonbar/swatson-casana/bar.sh b/lemonbar/swatson-casana/bar.sh
index 1e30d3c..7a4235a 100755
--- a/lemonbar/swatson-casana/bar.sh
+++ b/lemonbar/swatson-casana/bar.sh
@@ -2,6 +2,32 @@

div="%{F#0092ff}<>%{F-}%{B-}"

+# Global var, last epoch time we checked email
+# Update this when we call email() so that we can
+# call email() every second, but only call himalaya
+# once every minute
+
+LAST_EMAIL_CHECK_EPOCH=$(date +%s)
+EMAIL_STATE="Email: No new emails"
+
+email() {
+ EPOCH_NOW=$(date +%s)
+ DIFF=$((EPOCH_NOW - $LAST_EMAIL_CHECK_EPOCH))
+ if [ $DIFF -gt 60 ]; then
+ NEW_EMAILS=$(himalaya list -s 1 | grep ✷ | wc -l)
+ if [ $NEW_EMAILS -gt 0 ]; then
+ EMAIL_STATE="Email: ** New Emails **"
+ LAST_EMAIL_CHECK_EPOCH=$(date +%s)
+ else
+ EMAIL_STATE="Email: No new emails"
+ fi
+ fi
+
+ echo -n "$EMAIL_STATE"
+ echo -n " Last Checked: $LAST_EMAIL_CHECK_EPOCH "
+}
+
+
Clock() {
DATETIME=$(date "+%a %b %d, %T")

@@ -94,6 +120,6 @@ soundState() {

while true; do
sleep 1
- echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(batteryInfo)"
+ echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(batteryInfo) $div $(email)"
sleep 0.5
done