From c224d29547f7f4d38b6216f79f8305f533c506bf Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 22 Jul 2025 23:42:46 +0200 Subject: [PATCH] feat(mailsync): open email notify-send action --- bin/mailsync | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/mailsync b/bin/mailsync index 3a681f0..bdda018 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -80,7 +80,20 @@ syncandnotify() { from="$(sed -n "/^From:/ s|From: *|| p" "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" from="${from% *}" ; from="${from%\"}" ; from="${from#\"}" - notify "📧$from:" "$subject" + message_id=$(sed -n 's/^Message-ID: *\(<.*>\)$/\1/p' "$file") + ACTION=$(notify "📧$from:" "$subject" --action="open=Open email" "📧$from:" "$subject") + case "$ACTION" in + open) + if [ -n "$message_id" ]; then + $TERMINAL -e neomutt -f "$XDG_DATA_HOME/mail/$2/INBOX" -e "'push L~i$message_id\n\n'" + else + $TERMINAL -e neomutt -f "$XDG_DATA_HOME/mail/$2/INBOX" + fi + ;; + *) + echo "No valid action selected" + ;; + esac done ;; *) echo "No new mail for $2." ;;