diff --git a/shell/mu/.offlineimaprc b/shell/mu/.offlineimaprc new file mode 100644 index 00000000..4a68e34b --- /dev/null +++ b/shell/mu/.offlineimaprc @@ -0,0 +1,49 @@ +[general] +accounts = Lissner,Gmail +pythonfile = ~/.dotfiles/shell/mu/offlineimaprc.py + +[Account Gmail] +localrepository = LocalGmail +remoterepository = RepositoryGmail +autorefresh = 5 +quick = 10 +postsynchook = mu index --maildir ~/.mail/gmail.com +status_backend = sqlite + +[Repository LocalGmail] +type = Maildir +localfolders = ~/.mail/gmail.com +nametrans = nametrans + +[Repository RepositoryGmail] +type = Gmail +remoteusereval = get_pass("gmail.com")["user"] +remotepasseval = get_pass("gmail.com")["password"] +folderfilter = folder_filter +ssl = true +sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +nametrans = nametrans_reverse + +### +[Account Lissner] +localrepository = LocalLissner +remoterepository = RepositoryLissner +quick = 10 +postsynchook = mu index --maildir ~/.mail/lissner.net +status_backend = sqlite + +[Repository LocalLissner] +type = Maildir +localfolders = ~/.mail/lissner.net +nametrans = nametrans + +[Repository RepositoryLissner] +type = Gmail +remoteusereval = get_pass("lissner.net")["user"] +remotepasseval = get_pass("lissner.net")["password"] +folderfilter = folder_filter +ssl = true +sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +nametrans = nametrans_reverse diff --git a/shell/mu/install b/shell/mu/install new file mode 100755 index 00000000..0a875e66 --- /dev/null +++ b/shell/mu/install @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +case "$OSTYPE" in + darwin*) + brew install offlineimap + brew install mu --with-emacs + ;; + linux*) + if [[ -f /etc/arch-release ]]; then + pacaur --needed --noconfirm -S offlineimap mu + fi + ;; +esac diff --git a/shell/mu/offlineimaprc.py b/shell/mu/offlineimaprc.py new file mode 100644 index 00000000..fb0c05b5 --- /dev/null +++ b/shell/mu/offlineimaprc.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from subprocess import check_output +from re import sub + +def get_pass(account): + data = check_output("pass email/" + account, shell=True).splitlines() + password = data[0] + tmp = [x for x in data if x.startswith('address:')] + user = "" + if len(tmp) > 0: + user = tmp[0].split(":", 1)[1] + + return {"password": password, "user": user} + +def folder_filter(name): + return not (name in ['[Gmail]/Spam', '[Gmail]/Important', '[Gmail]/All Mail'] or + name.startswith('[Airmail]')) + +def nametrans(name): + return sub('^(Starred|Sent Mail|Drafts|Trash|All Mail|Spam)$', '[Gmail]/\\1', name) + +def nametrans_reverse(name): + return sub('^(\[Gmail\]/)', '', name)