24 lines
728 B
Bash
Executable File
24 lines
728 B
Bash
Executable File
#!/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
|
|
|
|
sleep 5
|
|
|
|
notmuch new
|