From b975159420f93fe34748524e0ae16817a216a9ad Mon Sep 17 00:00:00 2001 From: mxmehl Date: Mon, 24 Jul 2017 15:30:04 +0200 Subject: [PATCH] add hook to delete a mail permanently --- astroid/hooks/delmail | 21 +++++++++++++++++++++ astroid/keybindings | 1 + 2 files changed, 22 insertions(+) create mode 100755 astroid/hooks/delmail diff --git a/astroid/hooks/delmail b/astroid/hooks/delmail new file mode 100755 index 0000000..3623c7d --- /dev/null +++ b/astroid/hooks/delmail @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Deletes a mail permanently from the computer and the notmuch database +# Safeguard: only deletes a mail if it's tagged with $TAG, e.g. "del" or "trash" +# +# $1 = message id + +TAG="del" +LOG="/home/$USER/.config/astroid/hooks/hook.log" + +ID=$1 +FILE=$(notmuch search --exclude=false --output=files id:"${ID}") # get actual file path of MID + +if [[ $(notmuch search --exclude=false id:"${ID}" and tag:"${TAG}") ]]; then # only do something if mail is tagged "del" + rm ${FILE} # delete file + echo "[delmail] [SUCCESS] \"${FILE}\" tagged with \"${TAG}\" has been deleted. ID: ${ID}" >> $LOG +else + echo "[delmail] [ERROR] not tagged as \"${TAG}\" and therefore not deleted: ${ID}" >> $LOG +fi + +notmuch new diff --git a/astroid/keybindings b/astroid/keybindings index e11af60..f274897 100644 --- a/astroid/keybindings +++ b/astroid/keybindings @@ -40,3 +40,4 @@ thread_view.toggle_unread=u # Toggle the unread tag on the message, default: N # HOOKS thread_view.run(hooks::unspam %2 %1)=M-s +thread_view.run(hooks::delmail %2 %1)=M-d