|
@@ -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
|