#!/bin/bash # desktop-assistant tool: unread mail summary through mailctl (read-only). # Copyright (C) 2026 Danilo M. # # 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"