diff --git a/bumblebee/modules/watson.py b/bumblebee/modules/watson.py new file mode 100644 index 0000000..a359bf4 --- /dev/null +++ b/bumblebee/modules/watson.py @@ -0,0 +1,57 @@ +# pylint: disable=C0111,R0903 + +"""Displays the status of watson (time-tracking tool) + +Requires the following executable: + * watson +""" + +import bumblebee.input +import bumblebee.output +import bumblebee.engine +import bumblebee.util +import bumblebee.popup_v2 + +import logging +import re +import functools + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.text)) + self._tracking = False + self._project = "" + engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, + cmd=self.toggle) + + def toggle(self, widget): + self._project = "hit" + if self._tracking: + bumblebee.util.execute("watson stop") + else: + bumblebee.util.execute("watson restart") + self._tracking = not self._tracking + + def text(self, widget): + if self._tracking: + return self._project + else: + return "Paused" + + def update(self, widgets): + output = bumblebee.util.execute("watson status") + if re.match('No project started', output): + self._tracking = False + return + + self._tracking = True + m = re.search(r'Project (.+) started', output) + self._project = m.group(1) + + # + def state(self, widget): + return "on" if self._tracking else "off" + # return [widget.get("status", None), widget.get("period", None)] + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 7baf71d..8c92e15 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -262,5 +262,6 @@ "work": { "prefix": "" }, "break": { "prefix": "" } }, - "hddtemp": { "prefix": "" } + "hddtemp": { "prefix": "" }, + "watson": { "prefix": "" } } diff --git a/themes/icons/ionicons.json b/themes/icons/ionicons.json index cf7813a..170b07c 100644 --- a/themes/icons/ionicons.json +++ b/themes/icons/ionicons.json @@ -193,6 +193,6 @@ "off": { "prefix": "\uf24f" }, "paused": { "prefix": "\uf210" }, "on": { "prefix": "\uf488" } - } - + }, + "watson": { "prefix": "\uf2d1" } }