summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAdrien Lemaire <lemaire.adrien@gmail.com>2013-04-15 19:09:25 +0900
committerAdrien Lemaire <lemaire.adrien@gmail.com>2013-04-15 19:09:25 +0900
commit0ab72f49ecf89c3a73a8de4207612985749ceb3f (patch)
treeabc72a70b39893b9da70b9f6b2105b10291ace10 /examples
parent402d199c397405cb60c5a254cfd87608945f506c (diff)
define watchdog values to listen, and their action
Diffstat (limited to 'examples')
-rw-r--r--examples/pomodoro.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/examples/pomodoro.py b/examples/pomodoro.py
index 83c6643..397af44 100644
--- a/examples/pomodoro.py
+++ b/examples/pomodoro.py
@@ -15,12 +15,27 @@ class Py3status:
pomo = POMO
rest = SHORT_REST
nb_rest = NB_REST
+ default_response = {
+ 'full_text': '',
+ 'name': 'pomodoro',
+ }
def pomodoro(self, json, i3status_config):
"""
This function will update a timer in the i3status bar for 25 minutes,
then print a red "Break time" message for 5 minutes.
"""
+ status = self.get_status()
+
+ if status == 'stop':
+ self.pomo = POMO
+ self.rest = SHORT_REST
+ self.nb_rest = NB_REST
+ return self.default_response
+ elif status == 'pause':
+ return self.default_response
+
+ # Else run normally
if not self.pomo:
self.rest -= 1
timer = self.rest
@@ -36,16 +51,28 @@ class Py3status:
# Pomodoro or Rest is finished, send notification
self.send_notification()
- response = {
+ response = self.default_response.copy()
+ response.update({
'cached_until' : time(),
'color': i3status_config[color],
- 'self.full_text': '{}: {}'.format(
+ 'full_text': '{}: {}'.format(
self.full_text, str(timedelta(seconds=timer))[2:]),
- 'name': 'pomodoro',
- }
+ })
return (0, response)
+ def get_status(self):
+ """
+ Read the watchdog file and get the status value. Value is modifying via
+ i3 key mapping.
+
+ Value can be:
+ * start
+ * pause
+ * stop (default)
+ """
+ pass
+
def send_notification(self):
"""
:Requirements: libnotify, python-gobject