From a880134140f7ab8195c6651c2f64f614855c8dce Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 18 Oct 2026 11:00:53 +0200 Subject: mail: open accounts and messages in qtmaildir from the drawer and notifications qtmaildir now takes --account, --thread and --message, and hands them to a running window over its socket, so the drawer and the notifications can open the exact thing they show instead of just launching the client. mail-open.sh is the one place that turns an account and a thread into selectors, shared by both callers. It looks up the thread's newest unread message at click time rather than when the row or notification was built: by then it may have been read, and an empty lookup falls back to the whole thread instead of a miss in qtmaildir's status bar. The notification never had a working click: dunstify is not installed, so mail-notify.sh always took its notify-send fallback, which carried no action. It now uses notify-send -A NAME=Text, one action per listed thread (keyed by thread id, which is hex and so never holds the "=" separator) plus the account as default. The round trip through notifyd was checked: notifyctl action makes notify-send print the picked name. On the page, the account header opens the account and a thread row its newest unread message. Rows use TapHandler and HoverHandler because a MouseArea cannot fill a Column. Launches are detached: a first launch is the client itself, and the old reused Process would have killed it on the next click. Opening anything now closes the drawer rather than going back. Co-Authored-By: Claude Opus 5.5 --- desktop/modules/mail/mail-open.sh | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 desktop/modules/mail/mail-open.sh (limited to 'desktop/modules/mail/mail-open.sh') diff --git a/desktop/modules/mail/mail-open.sh b/desktop/modules/mail/mail-open.sh new file mode 100755 index 0000000..90877bd --- /dev/null +++ b/desktop/modules/mail/mail-open.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# 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. +# +# Opens qtmaildir on an account, or on a thread's newest unread message. +# Shared by the drawer's mail page and mail-notify.sh, so both open mail the +# same way. +# +# mail-open.sh [thread-id] +# +# A running qtmaildir takes the selectors over its socket and raises, so this +# never opens a second window. +# +# The message is looked up at click time rather than when the row or the +# notification was built: by then it may have been read, and an unread-only +# lookup that finds nothing falls back to the whole thread instead of a miss. +# Newest, because that is the message the row's date and the notification +# are about. + +set -u + +key="${1:?usage: mail-open.sh [thread-id]}" +tid="${2:-}" +args=(--account "$key") + +# notmuch thread ids are hex; anything else never reaches a query. +if [[ "$tid" =~ ^[0-9a-f]+$ ]]; then + id="$(notmuch search --format=json --output=messages --sort=newest-first --limit=1 \ + "thread:$tid and tag:unread and tag:inbox" 2>/dev/null | jq -r '.[0] // empty' 2>/dev/null)" + if [[ -n "$id" ]]; then + args+=(--message "$id") + else + args+=(--thread "$tid") + fi +fi + +exec "$HOME/bin/qtmaildir" "${args[@]}" -- cgit v1.2.3