[modules/notmuch_count] Update to latest API
This commit is contained in:
parent
fc3e5a8bb2
commit
ad3e3704ec
1 changed files with 12 additions and 20 deletions
|
@ -13,39 +13,31 @@ Dependencies:
|
||||||
notmuch (https://notmuchmail.org/)
|
notmuch (https://notmuchmail.org/)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import bumblebee.input
|
|
||||||
import bumblebee.output
|
|
||||||
import bumblebee.engine
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
import core.module
|
||||||
|
import core.widget
|
||||||
|
|
||||||
|
import util.cli
|
||||||
|
|
||||||
def __init__(self, engine, config):
|
class Module(core.module.Module):
|
||||||
super(Module, self).__init__(engine, config,
|
def __init__(self, config):
|
||||||
bumblebee.output.Widget(full_text=self.output)
|
super().__init__(config, core.widget.Widget(self.output))
|
||||||
)
|
|
||||||
self._notmuch_count_query = self.parameter('query', 'tag:unread AND NOT path:/.*Trash.*/')
|
|
||||||
self._notmuch_count = self.count_notmuch()
|
|
||||||
|
|
||||||
|
self.__notmuch_count_query = self.parameter('query', 'tag:unread AND NOT path:/.*Trash.*/')
|
||||||
|
|
||||||
def output(self, widget):
|
def output(self, widget):
|
||||||
self._notmuch_count = self.count_notmuch()
|
return self.__notmuch_count
|
||||||
return str(self._notmuch_count)
|
|
||||||
|
|
||||||
|
|
||||||
def state(self, widgets):
|
def state(self, widgets):
|
||||||
if self._notmuch_count == 0:
|
if self.__notmuch_count == 0:
|
||||||
return 'empty'
|
return 'empty'
|
||||||
return 'items'
|
return 'items'
|
||||||
|
|
||||||
|
def update(self):
|
||||||
def count_notmuch(self):
|
|
||||||
try:
|
try:
|
||||||
notmuch_count_cmd = 'notmuch count ' + self._notmuch_count_query
|
self.__notmuch_count = util.cli.execute('notmuch count {}'.format(self.__notmuch_count_query)).strip()
|
||||||
notmuch_count = int(bumblebee.util.execute(notmuch_count_cmd))
|
|
||||||
return notmuch_count
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return -1
|
self.__notmuch_count = 'n/a'
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue