changes to pomodoro (#714)
make sound optional allow setting colors allow setting inactive output
This commit is contained in:
parent
9dc69b980f
commit
2437439d1d
@ -16,6 +16,16 @@ class Pomodoro(IntervalModule):
|
|||||||
|
|
||||||
Left click starts/restarts timer.
|
Left click starts/restarts timer.
|
||||||
Right click stops it.
|
Right click stops it.
|
||||||
|
|
||||||
|
Example color settings.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
color_map = {
|
||||||
|
'stopped': '#2ECCFA',
|
||||||
|
'running': '#FFFF00',
|
||||||
|
'break': '#37FF00'
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
@ -27,13 +37,22 @@ class Pomodoro(IntervalModule):
|
|||||||
('long_break_duration', 'Long break duration in seconds'),
|
('long_break_duration', 'Long break duration in seconds'),
|
||||||
('short_break_count', 'Short break count before first long break'),
|
('short_break_count', 'Short break count before first long break'),
|
||||||
('format', 'format string, available formatters: current_pomodoro, '
|
('format', 'format string, available formatters: current_pomodoro, '
|
||||||
'total_pomodoro, time')
|
'total_pomodoro, time'),
|
||||||
|
('inactive_format', 'format string to display when no timer is running'),
|
||||||
|
('color', 'dictionary containing a mapping of statuses to colours')
|
||||||
)
|
)
|
||||||
required = ('sound',)
|
|
||||||
|
|
||||||
color_stopped = '#2ECCFA'
|
inactive_format = 'Start Pomodoro'
|
||||||
color_running = '#FFFF00'
|
|
||||||
color_break = '#37FF00'
|
color_map = {
|
||||||
|
'stopped': '#2ECCFA',
|
||||||
|
'running': '#FFFF00',
|
||||||
|
'break': '#37FF00'
|
||||||
|
}
|
||||||
|
|
||||||
|
color = None
|
||||||
|
sound = None
|
||||||
|
|
||||||
interval = 1
|
interval = 1
|
||||||
short_break_count = 3
|
short_break_count = 3
|
||||||
format = '☯ {current_pomodoro}/{total_pomodoro} {time}'
|
format = '☯ {current_pomodoro}/{total_pomodoro} {time}'
|
||||||
@ -52,6 +71,9 @@ class Pomodoro(IntervalModule):
|
|||||||
self.total_pomodoro = self.short_break_count + 1 # and 1 long break
|
self.total_pomodoro = self.short_break_count + 1 # and 1 long break
|
||||||
self.time = None
|
self.time = None
|
||||||
|
|
||||||
|
if self.color is not None and type(self.color) == dict:
|
||||||
|
self.color_map.update(self.color)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.time and datetime.utcnow() >= self.time:
|
if self.time and datetime.utcnow() >= self.time:
|
||||||
if self.state == RUNNING:
|
if self.state == RUNNING:
|
||||||
@ -80,11 +102,11 @@ class Pomodoro(IntervalModule):
|
|||||||
'total_pomodoro': self.total_pomodoro
|
'total_pomodoro': self.total_pomodoro
|
||||||
}
|
}
|
||||||
|
|
||||||
color = self.color_running if self.state == RUNNING else self.color_break
|
color = self.color_map['running'] if self.state == RUNNING else self.color_map['break']
|
||||||
text = self.format.format(**sdict)
|
text = self.format.format(**sdict)
|
||||||
else:
|
else:
|
||||||
text = 'Start pomodoro'
|
text = self.inactive_format
|
||||||
color = self.color_stopped
|
color = self.color_map['stopped']
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
'full_text': text,
|
'full_text': text,
|
||||||
@ -104,7 +126,8 @@ class Pomodoro(IntervalModule):
|
|||||||
notification = DesktopNotification(title='Alarm!', body=text)
|
notification = DesktopNotification(title='Alarm!', body=text)
|
||||||
notification.display()
|
notification.display()
|
||||||
|
|
||||||
subprocess.Popen(['aplay',
|
if self.sound is not None:
|
||||||
self.sound,
|
subprocess.Popen(['aplay',
|
||||||
'-q'],
|
self.sound,
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
'-q'],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user