From 7c7c01ea76d4d2a93397514f36f57ddded5f9247 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 6 Nov 2021 01:15:25 -0700 Subject: [PATCH] [polybar] Show the total number of unread emails --- polybar/.config/polybar/config | 8 +++++++- polybar/usr/bin/count-emails | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 polybar/usr/bin/count-emails 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))