aboutsummaryrefslogtreecommitdiffstats
path: root/polybar/usr/bin/count-emails
blob: 4bb75c1a7e1ea7c22295bf2a22b64a5ffa8d8c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env sh
# -*- mode: scheme; -*-
IFS=" "
exec scsh -o thread-fluids -s "$0" "$@"
!#

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