mail: Update to new neomutt structure

Updated notmuch to only be available for full-text search. Removed
complete afew configuration.

Added msmtp as mail sending agent.

Added structured neomutt configuration with custom bindings, built for
my personal gmail account, without any plaintext passwords revealed,
etc.

This is a reasonably well working mail setup,
which should provide a stable starting point for further refinements.

Additionally, added some functionality to `mail-check` script:
Allowed user to choose sync target for each run, by
passing in mbsync target (group/channel/..) as the argument.
Also, allows setting password file to use for script through env var,
and made imapfilter location less hard-coded to my system.
This commit is contained in:
Marty Oehme 2021-10-20 09:19:48 +02:00
parent 7a7ce3a296
commit a99982028e
Signed by: Marty
GPG key ID: B7538B8F50A1C800
9 changed files with 279 additions and 187 deletions

View file

@ -1,13 +1,33 @@
#!/usr/bin/env sh
# runs mbsync, with pre-hooks and post-hooks
# by default, first runs imapfilter
# and after indexes with notmuch
#
# Runs mbsync, with pre-hooks and post-hooks
# by default, the pre-hook first runs imapfilter
# and afterwards the post-hook indexes with notmuch.
#
# At the very least, you will have to set up a gpg
# encrypted file containing the password for your
# remote mailbox. It can be set directly below or
# through the environment variable
# `MBSYNC_PASSWORD_FILE` and should point to any
# gpg decryptable file.
#
# To run without invoking any hooks or retry attempts,
# run `checkmail raw`
# run `checkmail raw`.
# this will simply invoke a single isync run on all
# boxes with the correct config file set.
#
# To invoke mbsync for a specific group or channel,
# simply run it with `checkmail <channelname>` and
# it will only sync the correspondingly named.
#
# To run your own commands as hooks overwrite the
# environment variables `MBSYNC_PRE` and
# `MBSYNC_POST`. If you want to not have anything run
# for either of them the easiest way is to set the
# corresponding environment variable to true.
# Be careful which commands you put here since they
# will be evaluated without any special precautions.
#
# for more advanced, per-account/channel hooks, see
# https://sourceforge.net/p/isync/feature-requests/8/
@ -16,15 +36,16 @@
# MBSYNC_PRE="/bin/usr/cmd-to-run"
# MBSYNC_POST="/bin/usr/cmd-to-run"
# MBSYNC_NOTIFY=1
# MBSYNC_PASSWORD_FILE="/path/to/gpg/file.gpg"
PASSWORD_FILE="$HOME/.local/share/pass/misc/aerc-gmail-app-password.gpg"
PASSWORD_FILE="${MBSYNC_PASSWORD_FILE:-$HOME/.local/share/pass/misc/aerc-gmail-app-password.gpg}"
prehook() {
if [ -n "$MBSYNC_PRE" ]; then
eval "$MBSYNC_PRE"
return 0
fi
imapfilter -c "${XDG_CONFIG_HOME:-/home/marty/.config}/imapfilter/config.lua"
imapfilter -c "${XDG_CONFIG_HOME:-$HOME/.config}/imapfilter/config.lua"
}
posthook() {
@ -34,10 +55,6 @@ posthook() {
fi
notmuch new 2>/dev/null
afew --tag --new
afew --move-mail --new
afew --tag --new
notmuch_foldertags
countnew
}
@ -55,7 +72,7 @@ fail() {
}
checkmail() {
mbsync -c "${XDG_CONFIG_HOME:-$HOME/.config}/isync/mbsyncrc" -a
mbsync -c "${XDG_CONFIG_HOME:-$HOME/.config}/isync/mbsyncrc" "${1:--a}"
}
checkonline() {
@ -84,7 +101,7 @@ enablegpgagent() {
}
# send out a notification on new mail, to libnotify and stdout
notifymail() {
notify_on_new_mail() {
[ "${MBSYNC_NOTIFY:-1}" -eq 0 ] && return
if [ "${HASMAIL:-0}" -gt 0 ]; then
@ -105,18 +122,19 @@ notify() {
if [ "$1" = "raw" ]; then
checkmail
exit
# any other argument passed through selects mbsync targets
elif [ -n "$1" ]; then
selected_mailbox="$1"
fi
main() {
checkwarnuser
enablegpgagent
prehook
tries=0
while true; do
if checkmail; then
if checkmail "$selected_mailbox"; then
break
fi
@ -128,15 +146,7 @@ main() {
unset tries
posthook
notifymail
}
notmuch_foldertags() {
notmuch tag +dump -inbox -deleted -- folder:Dump and not folder:Inbox
notmuch tag +archived -inbox -deleted -- folder:Archive and not folder:Inbox
notmuch tag +deleted -inbox -archived -- folder:Trash and not folder:Inbox
notmuch tag -inbox -- not folder:Inbox
notify_on_new_mail
}
main