Changed Pomodoro icons, made the work/break periods variables

This commit is contained in:
Karthik Chikmagalur 2019-09-29 13:57:46 -07:00
parent d6072d0eb7
commit c4ba2195b3
2 changed files with 14 additions and 9 deletions

View file

@ -16,10 +16,12 @@ import bumblebee.engine
class Module(bumblebee.engine.Module): class Module(bumblebee.engine.Module):
def __init__(self, engine, config): def __init__(self, engine, config):
widgets = bumblebee.output.Widget(full_text=self.text) widgets = bumblebee.output.Widget(full_text=self.text)
self._work_period = 25 self.work_period = 25
self._play_period = 5 self.break_period = 5
self.remaining_time = datetime.timedelta(minutes=self._work_period) self.remaining_time = datetime.timedelta(minutes=self.work_period)
self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60))) self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60)))
# self.remaining_time_str = "{}min{}s ".format(int((self.remaining_time.seconds / 60)),
# round((self.remaining_time.seconds/60) % 1*60))
self.time = None self.time = None
self.pomodoro = { "state":"OFF", "type": ""} self.pomodoro = { "state":"OFF", "type": ""}
self._text = self.remaining_time_str + self.pomodoro["type"] self._text = self.remaining_time_str + self.pomodoro["type"]
@ -42,18 +44,20 @@ class Module(bumblebee.engine.Module):
if self.remaining_time.seconds <= 0: if self.remaining_time.seconds <= 0:
if self.pomodoro["type"] == "Work": if self.pomodoro["type"] == "Work":
self.pomodoro["type"] = "Break" self.pomodoro["type"] = "Break"
self.remaining_time = datetime.timedelta(minutes=self._work_period) self.remaining_time = datetime.timedelta(minutes=self.break_period)
elif self.pomodoro["type"] == "Break": elif self.pomodoro["type"] == "Break":
self.pomodoro["type"] = "Work" self.pomodoro["type"] = "Work"
self.remaining_time = datetime.timedelta(minutes=self._play_period) self.remaining_time = datetime.timedelta(minutes=self.work_period)
self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60))) self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60)))
# self.remaining_time_str = "{}min{}s ".format(int((self.remaining_time.seconds / 60)),
# round((self.remaining_time.seconds / 60) % 1 * 60))
self._text = self.remaining_time_str + self.pomodoro["type"] self._text = self.remaining_time_str + self.pomodoro["type"]
def timer_play_pause(self, widget): def timer_play_pause(self, widget):
if self.pomodoro["state"] == "OFF": if self.pomodoro["state"] == "OFF":
self.pomodoro = {"state": "ON", "type": "Work"} self.pomodoro = {"state": "ON", "type": "Work"}
self.remaining_time = datetime.timedelta(minutes=self._work_period) self.remaining_time = datetime.timedelta(minutes=self.work_period)
self.time = datetime.datetime.now() self.time = datetime.datetime.now()
elif self.pomodoro["state"] == "ON": elif self.pomodoro["state"] == "ON":
self.pomodoro["state"] = "PAUSED" self.pomodoro["state"] = "PAUSED"
@ -66,7 +70,7 @@ class Module(bumblebee.engine.Module):
def timer_reset(self, widget): def timer_reset(self, widget):
if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "PAUSED": if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "PAUSED":
self.pomodoro = {"state":"OFF", "type": "" } self.pomodoro = {"state":"OFF", "type": "" }
self.remaining_time = datetime.timedelta(minutes=self._work_period) self.remaining_time = datetime.timedelta(minutes=self.work_period)
def state(self, widget): def state(self, widget):
state = []; state = [];

View file

@ -224,8 +224,9 @@
"prefix": "" "prefix": ""
}, },
"pomodoro": { "pomodoro": {
"off": { "prefix": "🍅" }, "off": { "prefix": "" },
"paused": { "prefix": "" }, "paused": { "prefix": "" },
"on": { "prefix": "" } "work": { "prefix": "" },
"break": { "prefix": "" }
} }
} }