shell/mu: offlineimap => mbsync + refactor
This commit is contained in:
parent
4f66acff53
commit
921a445348
131
shell/mu/.mbsyncrc
Normal file
131
shell/mu/.mbsyncrc
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
########################################
|
||||||
|
# gmail.com
|
||||||
|
########################################
|
||||||
|
IMAPAccount gmail
|
||||||
|
Host imap.gmail.com
|
||||||
|
User hlissner@gmail.com
|
||||||
|
PassCmd "pass email/gmail.com | head -n1"
|
||||||
|
Port 993
|
||||||
|
AuthMechs LOGIN
|
||||||
|
SSLType IMAPS
|
||||||
|
CertificateFile /etc/ssl/certs/ca-certificates.crt
|
||||||
|
# CertificateFile /usr/local/etc/openssl/cert.pem # MacOS
|
||||||
|
|
||||||
|
##
|
||||||
|
# Remote
|
||||||
|
IMAPStore gmail-remote
|
||||||
|
Account gmail
|
||||||
|
|
||||||
|
# Local
|
||||||
|
MaildirStore gmail-local
|
||||||
|
Path ~/.mail/gmail.com/
|
||||||
|
Inbox ~/.mail/gmail.com/Inbox
|
||||||
|
|
||||||
|
## Connections
|
||||||
|
Channel gmail-all
|
||||||
|
Master :gmail-remote:"[Gmail]/All Mail"
|
||||||
|
Slave :gmail-local:"All Mail"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel gmail-inbox
|
||||||
|
Master :gmail-remote:"INBOX"
|
||||||
|
Slave :gmail-local:"Inbox"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel gmail-drafts
|
||||||
|
Master :gmail-remote:"[Gmail]/Drafts"
|
||||||
|
Slave :gmail-local:"Drafts"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel gmail-sent
|
||||||
|
Master :gmail-remote:"[Gmail]/Sent Mail"
|
||||||
|
Slave :gmail-local:"Sent Mail"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel gmail-trash
|
||||||
|
Master :gmail-remote:"[Gmail]/Trash"
|
||||||
|
Slave :gmail-local:"Trash"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
## Groups
|
||||||
|
Group gmail
|
||||||
|
Channel gmail-all
|
||||||
|
Channel gmail-inbox
|
||||||
|
Channel gmail-drafts
|
||||||
|
Channel gmail-sent
|
||||||
|
Channel gmail-trash
|
||||||
|
|
||||||
|
|
||||||
|
# ########################################
|
||||||
|
# # lissner.net
|
||||||
|
# ########################################
|
||||||
|
IMAPAccount lissner
|
||||||
|
Host imap.gmail.com
|
||||||
|
User henrik@lissner.net
|
||||||
|
PassCmd "pass email/lissner.net | head -n1"
|
||||||
|
Port 993
|
||||||
|
AuthMechs LOGIN
|
||||||
|
SSLType IMAPS
|
||||||
|
CertificateFile /etc/ssl/certs/ca-certificates.crt
|
||||||
|
# CertificateFile /usr/local/etc/openssl/cert.pem # MacOS
|
||||||
|
|
||||||
|
IMAPStore lissner-remote
|
||||||
|
Account lissner
|
||||||
|
|
||||||
|
MaildirStore lissner-local
|
||||||
|
Path ~/.mail/lissner.net/
|
||||||
|
Inbox ~/.mail/lissner.net/Inbox
|
||||||
|
|
||||||
|
## Connections
|
||||||
|
Channel lissner-all
|
||||||
|
Master :lissner-remote:"[Gmail]/All Mail"
|
||||||
|
Slave :lissner-local:"All Mail"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel lissner-inbox
|
||||||
|
Master :lissner-remote:"INBOX"
|
||||||
|
Slave :lissner-local:"Inbox"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel lissner-drafts
|
||||||
|
Master :lissner-remote:"[Gmail]/Drafts"
|
||||||
|
Slave :lissner-local:"Drafts"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel lissner-sent
|
||||||
|
Master :lissner-remote:"[Gmail]/Sent Mail"
|
||||||
|
Slave :lissner-local:"Sent Mail"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
Channel lissner-trash
|
||||||
|
Master :lissner-remote:"[Gmail]/Trash"
|
||||||
|
Slave :lissner-local:"Trash"
|
||||||
|
Create Both
|
||||||
|
Expunge Both
|
||||||
|
SyncState *
|
||||||
|
|
||||||
|
# ## Groups
|
||||||
|
Group lissner
|
||||||
|
Channel lissner-all
|
||||||
|
Channel lissner-inbox
|
||||||
|
Channel lissner-drafts
|
||||||
|
Channel lissner-sent
|
||||||
|
Channel lissner-trash
|
|
@ -1,13 +1,16 @@
|
||||||
[general]
|
[general]
|
||||||
accounts = Lissner,Gmail
|
accounts = Lissner,Gmail
|
||||||
pythonfile = ~/.dotfiles/shell/mu/offlineimaprc.py
|
maxsynaccounts = 2
|
||||||
|
pythonfile = ~/.dotfiles/shell/mu/lib.py
|
||||||
|
fsync = False
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
|
||||||
[Account Gmail]
|
[Account Gmail]
|
||||||
localrepository = LocalGmail
|
localrepository = LocalGmail
|
||||||
remoterepository = RepositoryGmail
|
remoterepository = RepositoryGmail
|
||||||
autorefresh = 5
|
postsynchook = mu index --maildir ~/.mail
|
||||||
quick = 10
|
|
||||||
postsynchook = mu index --maildir ~/.mail/gmail.com
|
|
||||||
status_backend = sqlite
|
status_backend = sqlite
|
||||||
|
|
||||||
[Repository LocalGmail]
|
[Repository LocalGmail]
|
||||||
|
@ -20,6 +23,7 @@ type = Gmail
|
||||||
remoteusereval = get_pass("gmail.com")["user"]
|
remoteusereval = get_pass("gmail.com")["user"]
|
||||||
remotepasseval = get_pass("gmail.com")["password"]
|
remotepasseval = get_pass("gmail.com")["password"]
|
||||||
folderfilter = folder_filter
|
folderfilter = folder_filter
|
||||||
|
realdelete=no
|
||||||
ssl = true
|
ssl = true
|
||||||
sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS
|
sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS
|
||||||
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
|
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
|
||||||
|
@ -29,8 +33,7 @@ nametrans = nametrans_reverse
|
||||||
[Account Lissner]
|
[Account Lissner]
|
||||||
localrepository = LocalLissner
|
localrepository = LocalLissner
|
||||||
remoterepository = RepositoryLissner
|
remoterepository = RepositoryLissner
|
||||||
quick = 10
|
postsynchook = mu index --maildir ~/.mail
|
||||||
postsynchook = mu index --maildir ~/.mail/lissner.net
|
|
||||||
status_backend = sqlite
|
status_backend = sqlite
|
||||||
|
|
||||||
[Repository LocalLissner]
|
[Repository LocalLissner]
|
||||||
|
@ -43,6 +46,7 @@ type = Gmail
|
||||||
remoteusereval = get_pass("lissner.net")["user"]
|
remoteusereval = get_pass("lissner.net")["user"]
|
||||||
remotepasseval = get_pass("lissner.net")["password"]
|
remotepasseval = get_pass("lissner.net")["password"]
|
||||||
folderfilter = folder_filter
|
folderfilter = folder_filter
|
||||||
|
realdelete=no
|
||||||
ssl = true
|
ssl = true
|
||||||
sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS
|
sslcacertfile = /usr/local/etc/openssl/cert.pem # This will only work for macOS
|
||||||
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
|
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
32
shell/mu/lib.py
Executable file
32
shell/mu/lib.py
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from subprocess import check_output
|
||||||
|
from re import sub
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def get_pass(account):
|
||||||
|
data = check_output("/usr/bin/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]/Starred',
|
||||||
|
'[Gmail]/All Mail'] or
|
||||||
|
name.startswith('[Airmail]'))
|
||||||
|
|
||||||
|
def nametrans(name):
|
||||||
|
return sub('^INBOX/(Starred|Sent Mail|Drafts|Trash|All Mail|Spam)$', '[Gmail]/\\1', name)
|
||||||
|
|
||||||
|
def nametrans_reverse(name):
|
||||||
|
return sub('^(\[Gmail\])', 'INBOX.', name)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(get_pass(sys.argv[1].strip())['password'])
|
|
@ -1,24 +0,0 @@
|
||||||
#!/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'] 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)
|
|
Loading…
Reference in a new issue