diff options
author | Aaron LI <aaronly.me@outlook.com> | 2015-02-03 13:58:25 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2015-02-03 13:58:25 +0800 |
commit | 158883aba19b1dced08ad02cb87bd07cb90dfb0c (patch) | |
tree | e7b3b4817e062ded9c9384170bbdabd3f8c000f6 /.offlineimap | |
parent | 5d92d1ede1d4b6945dde4019400b86c34e4466d5 (diff) | |
download | dotfiles-158883aba19b1dced08ad02cb87bd07cb90dfb0c.tar.bz2 |
Updated configs of offlineimap, msmtp. Added notmuch-config.
Diffstat (limited to '.offlineimap')
-rw-r--r-- | .offlineimap/offlineimap.py | 17 | ||||
-rwxr-xr-x | .offlineimap/postsync.sh | 26 |
2 files changed, 37 insertions, 6 deletions
diff --git a/.offlineimap/offlineimap.py b/.offlineimap/offlineimap.py index 50f91e2..e3ae422 100644 --- a/.offlineimap/offlineimap.py +++ b/.offlineimap/offlineimap.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # -# Ref: -# Encrypt OfflineIMAP Password -# http://unix.stackexchange.com/questions/44214/encrypt-offlineimap-password +# Add support of encrypting password with gpg2 for OfflineIMAP. +# Provide function 'mailpasswd' to decrypt the password. # # Configurations: # [general] @@ -12,7 +11,11 @@ # remotepasseval = mailpasswd("<accountname>") # ... # -# 2014/06/20 +# Reference: +# [1] Encrypt OfflineIMAP Password +# http://unix.stackexchange.com/questions/44214/encrypt-offlineimap-password +# +# Updated: 2015/02/02 # import os @@ -21,7 +24,8 @@ import subprocess def mailpasswd(account): account = os.path.basename(account) path = '{0}/.offlineimap/{1}.gpg'.format(os.environ['HOME'], account) - args = ['gpg', '--use-agent', '--quiet', '--batch', '-d', path] + args = ['gpg2', '--for-your-eyes-only', '--no-tty', + '--quiet', '--batch', '--decrypt', path] try: return subprocess.check_output(args).strip() except subprocess.CalledProcessError: @@ -32,7 +36,8 @@ def mailpasswd(account): #def mailpasswd(account): # account = os.path.basename(account) # path = '{0}/.offlineimap/{1}.gpg'.format(os.environ['HOME'], account) -# args = ['gpg', '--use-agent', '--quiet', '--batch', '-d', path] +# args = ['gpg2', '--for-your-eyes-only', '--no-tty', +# '--quiet', '--batch', '--decrypt', path] # proc = subprocess.Popen(args, stdout=subprocess.PIPE) # output = proc.communicate()[0].strip() # retcode = proc.wait() diff --git a/.offlineimap/postsync.sh b/.offlineimap/postsync.sh new file mode 100755 index 0000000..c5a3985 --- /dev/null +++ b/.offlineimap/postsync.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# OfflineIMAP postsynchook +# +# Weitian LI +# 2015/02/02 +# + +## Check new mails & send notification +MAILDIR="${HOME}/Mail/" +newmails=0 +for d in `find ${MAILDIR} -maxdepth 2 -type d -iname '*inbox'`; do + n=`ls ${d}/new/ | wc -l` + newmails=`expr ${newmails} + ${n}` +done + +if [ ${newmails} -gt 0 ] && which notify-send >/dev/null 2>&1; then + export DISPLAY=":0" + export XAUTHORITY="${HOME}/.Xauthority" + notify-send -i 'mail-unread' -a "OfflineIMAP" \ + "OfflineIMAP: Received ${newmails} new mail(s)!" +fi + +## Invoke notmuch to index mails +notmuch new + |