summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUltrabug <ultrabug@ultrabug.net>2015-03-20 10:19:03 +0100
committerUltrabug <ultrabug@ultrabug.net>2015-03-20 10:19:03 +0100
commit56f92dafc76df816dbb86012da63e1c01a2371c7 (patch)
tree9992c9e424d8105c378be4e4452aba8f4fd295a7
parentdbbe4cdc6bf9d428f6fa5e2fb3c7a8dd6198abcd (diff)
parent102313553232fae442a17d2c6193ee43b5852d22 (diff)
Merge pull request #81 from rixx/master
Pause capability and documentation for Pomodoro module by @rixx
-rw-r--r--py3status/modules/pomodoro.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/py3status/modules/pomodoro.py b/py3status/modules/pomodoro.py
index 63068b5..ecb3f57 100644
--- a/py3status/modules/pomodoro.py
+++ b/py3status/modules/pomodoro.py
@@ -49,20 +49,42 @@ class Py3status:
def on_click(self, i3s_output_list, i3s_config, event):
"""
- Handles click events
+ Handles click events:
+ - left click starts an inactive counter and pauses a running
+ Pomodoro
+ - middle click resets everything
+ - right click starts (and ends, if needed) a break
+
"""
if event['button'] == 1:
if self.status == 'stop':
self.status = 'start'
self.__play_sound(self.sound_pomodoro_start)
- self.run = True
+ self.run = True
+
+ elif self.status == 'break':
+ self.run = True
+
+ elif self.status == 'start':
+ if self.run:
+ self.status = 'pause'
+ self.run = False
+ else:
+ self.run = True
+
+ elif self.status == 'pause':
+ self.status = 'start'
+ self.run = True
elif event['button'] == 2:
self.__setup('stop')
self.run = False
elif event['button'] == 3:
- self.__setup('pause')
+ if self.status == 'break':
+ self.__setup('start')
+ else:
+ self.__setup('break')
self.run = False
@property
@@ -110,7 +132,7 @@ class Py3status:
self.timer = self.timer_pomodoro
self.time_window = self.timer
- elif status == 'pause':
+ elif status == 'break':
self.prefix = 'Break #%d' % self.breaks
if self.breaks > self.max_breaks:
self.timer = self.timer_long_break
@@ -130,12 +152,13 @@ class Py3status:
self.alert = True
self.run = False
self.__i3_nagbar()
+
if self.status == 'start':
- self.__setup('pause')
- self.status = 'pause'
+ self.__setup('break')
+ self.status = 'break'
self.__play_sound(self.sound_pomodoro_end)
- elif self.status == 'pause':
+ elif self.status == 'break':
self.__setup('start')
self.status = 'start'
self.__play_sound(self.sound_break_end)
@@ -168,7 +191,7 @@ class Py3status:
if self.status == 'start':
response['color'] = i3s_config['color_good']
- elif self.status == 'pause':
+ elif self.status == 'break':
response['color'] = i3s_config['color_degraded']
else:
response['color'] = i3s_config['color_bad']