hook to move a mail back to the inbox

This commit is contained in:
2018-07-19 11:42:57 +02:00
parent 210b223c34
commit 70da920f7f
2 changed files with 20 additions and 0 deletions

19
astroid/hooks/move2inbox Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
#
# Moves a file to the INBOX directory
#
# $1 = message id
MAIL_ROOT=`notmuch config get database.path`
DIR_INBOX="INBOX"
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 ! $(echo ${FILE} | grep -q "${MAIL_ROOT}/${DIR_INBOX}/"); then # if mail is not in INBOX already
mv "${FILE}" "${MAIL_ROOT}/${DIR_INBOX}/cur/"
echo "[move2inbox] [SUCCESS] moved ${FILE} to ${MAIL_ROOT}/${DIR_INBOX}/cur/" >> $LOG
else
echo "[move2inbox] [ERROR] already in \"${DIR_INBOX}\" directory: ${FILE}" >> $LOG
fi

View File

@@ -41,3 +41,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
thread_view.run(hooks::move2inbox %2 %1)=M-i