Browse Source

Updates to lemonbar/email. Lemonbar needs work

Simon Watson 3 years ago
parent
commit
abc693dadc
2 changed files with 28 additions and 2 deletions
  1. 1 1
      himalaya/.himalayarc
  2. 27 1
      lemonbar/swatson-casana/bar.sh

+ 1 - 1
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

+ 27 - 1
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