diff --git a/.gitignore b/.gitignore index 8e2208a..6139980 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ vim/autoload/* vim/spell/*.spl vim/plugged vim/.netrwhist -zsh/transient/* + +# Ignore anything that is transient +*/transient/* diff --git a/emacs/doom.d/config.el b/emacs/doom.d/config.el index c93e31f..e9426fb 100644 --- a/emacs/doom.d/config.el +++ b/emacs/doom.d/config.el @@ -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) + ) diff --git a/emacs/doom.d/init.el b/emacs/doom.d/init.el index 7d5e4ef..ff95262 100644 --- a/emacs/doom.d/init.el +++ b/emacs/doom.d/init.el @@ -186,7 +186,7 @@ (web +lsp) ; the tubes :email - ;;(mu4e +gmail) + mu4e ;;notmuch ;;(wanderlust +gmail) diff --git a/mbsync/authinfo.template b/mbsync/authinfo.template new file mode 100644 index 0000000..8c7587f --- /dev/null +++ b/mbsync/authinfo.template @@ -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 diff --git a/mbsync/file b/mbsync/file new file mode 100644 index 0000000..113cf61 --- /dev/null +++ b/mbsync/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 diff --git a/mbsync/makefile b/mbsync/makefile new file mode 100644 index 0000000..b406ba3 --- /dev/null +++ b/mbsync/makefile @@ -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" diff --git a/mbsync/mbsyncrc b/mbsync/mbsyncrc new file mode 100644 index 0000000..2eff049 --- /dev/null +++ b/mbsync/mbsyncrc @@ -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 diff --git a/mbsync/mk_authinfo b/mbsync/mk_authinfo new file mode 100755 index 0000000..ef37ad2 --- /dev/null +++ b/mbsync/mk_authinfo @@ -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 +