diff options
Diffstat (limited to 'examples/tools/mail.sh')
| -rwxr-xr-x | examples/tools/mail.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/tools/mail.sh b/examples/tools/mail.sh new file mode 100755 index 0000000..4e0e9c1 --- /dev/null +++ b/examples/tools/mail.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# desktop-assistant tool: unread mail summary through mailctl (read-only). +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# mail.sh [QUERY]: thread count and the 10 newest threads for a notmuch +# query, default unread mail in the inbox, across every account. Only +# mailctl's search runs here: nothing is tagged, moved or synced. +# MAILCTL overrides the command (default mailctl.py on PATH). + +set -uo pipefail + +query="${1:-tag:unread and tag:inbox}" +json=$("${MAILCTL:-mailctl.py}" search "$query" --json) || { echo "mail search failed" >&2; exit 1; } +jq -r 'length as $n + | if $n == 0 then "no threads match" + else "\($n) threads", (.[:10][] | "\(.date_relative), \(.authors): \(.subject)") + end' <<<"$json" |
