Merge pull request #597 from bendardenne/watson
Added module for watson
This commit is contained in:
commit
c77c5c9c0d
3 changed files with 61 additions and 3 deletions
57
bumblebee/modules/watson.py
Normal file
57
bumblebee/modules/watson.py
Normal file
|
@ -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
|
|
@ -262,5 +262,6 @@
|
|||
"work": { "prefix": "" },
|
||||
"break": { "prefix": "" }
|
||||
},
|
||||
"hddtemp": { "prefix": "" }
|
||||
"hddtemp": { "prefix": "" },
|
||||
"watson": { "prefix": "" }
|
||||
}
|
||||
|
|
|
@ -193,6 +193,6 @@
|
|||
"off": { "prefix": "\uf24f" },
|
||||
"paused": { "prefix": "\uf210" },
|
||||
"on": { "prefix": "\uf488" }
|
||||
}
|
||||
|
||||
},
|
||||
"watson": { "prefix": "\uf2d1" }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue