dotfiles/conf.d/astroid/hooks/untrash
2021-02-21 01:15:09 +01:00

36 lines
865 B
Bash
Executable File

#!/bin/bash
# File : untrash
# Author : Jeff LANCE <email@jefflance.me>
# Date : 10.02.2015
# Last Modified Date: 04.05.2020
# Last Modified By : Jeff LANCE <email@jefflance.me>
#
# $1 = message id
echo "[ASTROID] $(basename $0)"
# All directory names relative to mail folder's root
DIR_TRASH="trash" # Trash directory path
DIR_INBOX="inbox" # Inbox directory path
# Get thread ID and message ID
TID=$1
MID=$2
FILE=$(notmuch search --exclude=false --output=files\
"thread:$TID" "${MID:+id:$MID}")
# Only do something if mail was deleted
if [[ $(notmuch search "thread:$TID" "${MID:+id:$MID}" and tag:deleted and folder:/${DIR_TRASH}/) ]]; then
# untrash mail and reset inbox status
notmuch tag -deleted +inbox -- "thread:$TID" "${MID:+id:$MID}"
fi
# Move mail with afew
afew --move-mails
exit 0
# vim:ft=sh