diff options
author | Tom Willemse | 2022-05-26 23:32:52 -0700 |
---|---|---|
committer | Tom Willemse | 2022-05-26 23:32:52 -0700 |
commit | 6c3bf820142ffcb4f3f36ff2a845babebd3ed086 (patch) | |
tree | e1fb96050b42180ff21cc9eaa091cddb6a40d6bf | |
parent | 74706d063c2254e6147158aaf4e7c3321cfdcf3f (diff) | |
download | new-dotfiles-6c3bf820142ffcb4f3f36ff2a845babebd3ed086.tar.gz new-dotfiles-6c3bf820142ffcb4f3f36ff2a845babebd3ed086.zip |
[polybar] Use notmuch if available to count unread emails
-rwxr-xr-x | polybar/usr/bin/count-emails | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/polybar/usr/bin/count-emails b/polybar/usr/bin/count-emails index 787d69d..4bb75c1 100755 --- a/polybar/usr/bin/count-emails +++ b/polybar/usr/bin/count-emails @@ -1,17 +1,17 @@ #!/usr/bin/env sh # -*- mode: scheme; -*- IFS=" " -exec scsh -s "$0" "$@" +exec scsh -o thread-fluids -s "$0" "$@" !# -(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)) +(if (exec-path-search "notmuch" (thread-fluid exec-path-list)) + (display (length (run/sexp (notmuch search --output=files --format=sexp tag:unread)))) + (begin + (let* ((mail-root (string-append (getenv "HOME") "/documents/mail")) + (unread-emails + (run/sexp (pipe (find ,mail-root -type f -name "*:2,*" -and -not -name "*:2,*S*") + (wc -l)))) + (new-emails + (run/sexp (pipe (find ,mail-root -type f -wholename "*/new/*") + (wc -l))))) + (display (+ unread-emails new-emails))))) |