Merge pull request #109 from teto/notmuch_autoload

This patch allows the notmuch backend to retrieve the notmuch database p...
This commit is contained in:
enkore 2014-09-04 14:00:48 +02:00
commit 850841f9c8

View File

@ -4,7 +4,8 @@
# note that this needs the notmuch python bindings. For more info see: # note that this needs the notmuch python bindings. For more info see:
# http://notmuchmail.org/howto/#index4h2 # http://notmuchmail.org/howto/#index4h2
import notmuch import notmuch
import configparser
import os
from i3pystatus.mail import Backend from i3pystatus.mail import Backend
@ -15,9 +16,27 @@ class Notmuch(Backend):
and "unread" and "unread"
""" """
settings = required = ("db_path",) settings = (
("db_path","Path to the directory of your notmuch database"),
)
db_path = None;
def init(self): def init(self):
if not self.db_path:
defaultConfigFilename= os.path.expanduser("~/.notmuch-config")
config = configparser.RawConfigParser()
# read tries to read and returns successfully read filenames
successful = config.read( [
os.environ.get("NOTMUCH_CONFIG",defaultConfigFilename),
defaultConfigFilename
]
)
self.db_path = config.get("database","path")
self.db = notmuch.Database(self.db_path) self.db = notmuch.Database(self.db_path)
@property @property