aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/waybar-mail.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mail-overview/waybar-mail.sh')
-rwxr-xr-xmail-overview/waybar-mail.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/mail-overview/waybar-mail.sh b/mail-overview/waybar-mail.sh
index 06f8427..ee07ecb 100755
--- a/mail-overview/waybar-mail.sh
+++ b/mail-overview/waybar-mail.sh
@@ -30,10 +30,12 @@ emit() {
local n
n="$(notmuch count "$QUERY" 2>/dev/null)"
- # notmuch exits 0 even for a malformed query, printing something that is
- # not a count, so the exit status is not the test: the output is. Anything
- # that is not a plain number is a failure, and a failure must not render
- # as "no new mail".
+ # The output is the test, not the exit status. notmuch fails two different
+ # ways: a rejected query prints nothing and exits 1, while a query Xapian
+ # merely misparses ('tag:unread and ((') returns a plausible wrong number
+ # and exits 0. Only the first is detectable, and it is the one that matters
+ # here, because empty output would otherwise render as "no new mail". The
+ # second is why QUERY is a fixed string and not built from anything.
if [[ ! "$n" =~ ^[0-9]+$ ]]; then
printf '{"text":"!","tooltip":"notmuch count failed","class":"error"}\n'
return