aboutsummaryrefslogtreecommitdiffstats
path: root/polybar
diff options
context:
space:
mode:
authorGravatar Tom Willemse2021-11-06 01:15:25 -0700
committerGravatar Tom Willemse2021-11-06 01:15:25 -0700
commit7c7c01ea76d4d2a93397514f36f57ddded5f9247 (patch)
tree2cb41b2ff2ad0b26dd667334b0ce8efaa78584ab /polybar
parent9872c1c4c2f56f14cdeedad4dece3c0ddac73b42 (diff)
downloadnew-dotfiles-7c7c01ea76d4d2a93397514f36f57ddded5f9247.tar.gz
new-dotfiles-7c7c01ea76d4d2a93397514f36f57ddded5f9247.zip
[polybar] Show the total number of unread emails
Diffstat (limited to 'polybar')
-rw-r--r--polybar/.config/polybar/config8
-rwxr-xr-xpolybar/usr/bin/count-emails15
2 files changed, 22 insertions, 1 deletions
diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config
index 5ab46b0..bc37764 100644
--- a/polybar/.config/polybar/config
+++ b/polybar/.config/polybar/config
@@ -36,7 +36,7 @@ font-2 = siji:pixelsize=10;1
modules-left = ewmh xwindow
modules-center =
-modules-right = pulseaudio xkeyboard vpn date
+modules-right = email pulseaudio xkeyboard vpn date
tray-position = center
tray-padding = 0
@@ -222,3 +222,9 @@ interval = 5
format-underline = #a8547e
format-background = #3f1f32
format-padding = 3
+
+[module/email]
+type = custom/script
+exec = count-emails
+interval = 5
+format-prefix = " "
diff --git a/polybar/usr/bin/count-emails b/polybar/usr/bin/count-emails
new file mode 100755
index 0000000..98a2573
--- /dev/null
+++ b/polybar/usr/bin/count-emails
@@ -0,0 +1,15 @@
+#!/usr/bin/env -S scsh -s
+;; -*- mode: scheme; -*-
+!#
+
+(define mail-root (string-append (getenv "HOME") "/documents/mail"))
+
+(define unread-emails
+ (run/sexp (pipe (find ,mail-root -type f -name "*:2,*" -and -not -name "*:2,*S*")
+ (wc -l))))
+
+(define new-emails
+ (run/sexp (pipe (find ,mail-root -type f -wholename "*/new/*")
+ (wc -l))))
+
+(display (+ unread-emails new-emails))