Adding support for mu4e, mu, & mbsync

This commit is contained in:
James Patrick 2020-05-28 13:28:26 -04:00
parent 5cb619ab09
commit 5d85602d49
8 changed files with 180 additions and 3 deletions

4
.gitignore vendored
View File

@ -17,4 +17,6 @@ vim/autoload/*
vim/spell/*.spl
vim/plugged
vim/.netrwhist
zsh/transient/*
# Ignore anything that is transient
*/transient/*

View File

@ -24,8 +24,72 @@
;; org-journal-file-format
(customize-set-variable 'org-journal-date-format "%A, %d %B %Y")
(setq doom-localleader-key ",")
;; Have projectile automatically check code.
(setq projectile-project-search-path '("~/src/" "~/Code/"))
(setq doom-localleader-key ",")
(set-email-account! "ProtonMail"
'((mu4e-sent-folder . "/Sent")
(mu4e-drafts-folder . "/Drafts")
(mu4e-trash-folder . "/Trash")
(mu4e-refile-folder . "/All Mail")
(mu4e-update-interval . 300)
(mu4e-change-filenames-when-moving . t)
(user-mail-address . "james@jpatrick.io")
(message-send-mail-function . 'smtpmail-send-it)
(smtpmail-auth-credentials . "~/.authinfo.gpg")
(smtpmail-smtp-service . 1025)
(smtpmail-smtp-server . "127.0.0.1")
(smtpmail-smtp-user . "james@jpatrick.io")
)
t)
(setq
message-send-mail-function 'smtpmail-send-it
smtpmail-auth-credentials "~/.authinfo.gpg"
smtpmail-smtp-server "127.0.0.1"
smtpmail-smtp-service 1025)
(add-to-list 'gnutls-trustfiles "~/.config/mbsync/transient/bridge.crt")
(defcustom mu4e-bookmarks
'(( :name "Unread messages"
:query "flag:unread AND NOT flag:trashed"
:key ?u)
( :name "Today's messages"
:query "date:today..now"
:key ?t)
( :name "Last 7 days"
:query "date:7d..now"
:hide-unread t
:key ?w)
( :name "Messages with images"
:query "mime:image/*"
:key ?p))
"List of pre-defined queries that are shown on the main screen.
Each of the list elements is a plist with at least:
:name - the name of the query
:query - the query expression
:key - the shortcut key.
Optionally, you add the following:
:hide - if t, bookmark is hdden from the main-view and speedbar.
:hide-unread - do not show the counts of unread/total number
of matches for the query. This can be useful if a bookmark uses
a very slow query. :hide-unread is implied from :hide.
"
:type '(repeat (plist))
:group 'mu4e)
(add-to-list 'mu4e-bookmarks
'( :name "Recent Account Msgs"
:query "maildir:/Folders/subscriptions date 7d..now AND flag:unread"
:key ?s)
)
(add-to-list 'mu4e-bookmarks
'( :name "Unread Personal"
:query "maildir:/INBOX date 7d..now AND flag:unread"
:key ?i)
)

View File

@ -186,7 +186,7 @@
(web +lsp) ; the tubes
:email
;;(mu4e +gmail)
mu4e
;;notmuch
;;(wanderlust +gmail)

2
mbsync/authinfo.template Normal file
View File

@ -0,0 +1,2 @@
machine 127.0.0.1 login james@jpatrick.io port 1143 password PASSWORD_PROVIDED_BY_BRIDGE
machine 127.0.0.1 login james@jpatrick.io port 1025 password PASSWORD_PROVIDED_BY_BRIDGE

2
mbsync/file Normal file
View File

@ -0,0 +1,2 @@
machine 127.0.0.1 login USERNAME_HERE@protonmail.com port 1143 password aaa
machine 127.0.0.1 login USERNAME_HERE@protonmail.com port 1025 password aaa

46
mbsync/makefile Normal file
View File

@ -0,0 +1,46 @@
# -*- mode: makefile-gmake; -*-
SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include ../lib/shared.mk
TARGET := $(XDG_DIR)/mbsync
RC_TARGET := ~/.mbsyncrc
TRANSIENT_DIR := $(SRC)/transient
install: | init update
init:
if (( $$+commands[mbsync] )) ; then
$(report) header "Setting up mbsync"
$(mk_link) $(SRC) $(TARGET)
$(mk_link) $(SRC)/mbsyncrc $(RC_TARGET)
$(MAKE) -C $(SRC) update_cert
[[ ! -e ~/.authinfo.gpg ]] \
&& $(report) "warn" "You need to setup the authinfo.gpg run \n > $(SRC)/mk_authinfo" \
|| $(report) "debug" "authinfo.gpg already installed"
else
$(report) debug "mbsync not installed. Skipping."
fi
update_cert:
if [[ ! -e $(TRANSIENT_DIR) ]] ; then
$(report) debug "$(TRANSIENT_DIR) didn't exist. Creating one."
mkdir $(TRANSIENT_DIR)
fi
echo "" \
| openssl s_client -starttls imap --connect 127.0.0.1:1143 -showcerts 2>/dev/null \
| sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' \
> $(TRANSIENT_DIR)/bridge.crt \
&& $(report) pass "Cert from proton bridge downloaded." \
|| $(report) error "Error while fetching cert. Is bridge running?"
update:
remove:
$(report) header "Removing mbsync"
$(rm_link) $(TARGET)
rm -rf $(TRANSIENT_DIR) ; $(report) "Deleting $(TRANSIENT_DIR)"
$(rm_link) $(RC_TARGET)
rm ~/.authinfo.gpg ; $(report) "Deleting authinfo"

26
mbsync/mbsyncrc Normal file
View File

@ -0,0 +1,26 @@
# These settings can also go under an "Account" section, but then the
# "IMAPStore" section needs to reference the account. This is not
# needed for just one store per account.
IMAPStore mailbox-remote
Host 127.0.0.1
Port 1143
User james@jpatrick.io
PassCmd "gpg2 -q -d ~/.authinfo.gpg | awk 'FNR == 1 {print $8}'"
SSLType STARTTLS
CertificateFile ~/.config/mbsync/transient/bridge.crt
MaildirStore mailbox-local
Path ~/.mail/
Inbox ~/.mail/INBOX
SubFolders Verbatim
Channel mailbox
Master :mailbox-remote:
Slave :mailbox-local:
Patterns *
Create Slave
#Expunge Both
SyncState *
Group protonmail
Channel inbox

35
mbsync/mk_authinfo Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env zsh
function cleanup(){
if (( $+commands[shred] )) ; then
shred transient/authinfo*
elif (( $+commands[srm] )) ; then
srm transient/authinfo*
elif ; then
echo UNABLE TO FIND A WAY TO SECURELY DELETE THIS.
exit -1
fi
rm transient/authinfo*
}
trap cleanup EXIT
cd $(dirname $0)
if [[ ! -e ./transient ]] ; then
mkdir transient
fi
if [[ ! -e ~/transient/authinfo ]] ; then
echo "Hello. I need the bridge password for this to work."
read _password\?"password: " asdaD
sed "s/PASSWORD_PROVIDED_BY_BRIDGE/${_password}/g" authinfo.template \
> transient/authinfo
unset _password
fi
gpg -e -r james@jpatrick.io transient/authinfo
mv transient/authinfo.gpg ~/.authinfo.gpg