add hook to delete a mail permanently
This commit is contained in:
21
astroid/hooks/delmail
Executable file
21
astroid/hooks/delmail
Executable file
@@ -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
|
||||||
@@ -40,3 +40,4 @@ thread_view.toggle_unread=u # Toggle the unread tag on the message, default: N
|
|||||||
|
|
||||||
# HOOKS
|
# HOOKS
|
||||||
thread_view.run(hooks::unspam %2 %1)=M-s
|
thread_view.run(hooks::unspam %2 %1)=M-s
|
||||||
|
thread_view.run(hooks::delmail %2 %1)=M-d
|
||||||
|
|||||||
Reference in New Issue
Block a user