[polybar] Show the total number of unread emails

This commit is contained in:
Tom Willemse 2021-11-06 01:15:25 -07:00
parent 9872c1c4c2
commit 7c7c01ea76
2 changed files with 22 additions and 1 deletions

View file

@ -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 = " "

15
polybar/usr/bin/count-emails Executable file
View file

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