From d6072d0eb718f727baaa7727256e34e6625fc9bf Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Sat, 28 Sep 2019 16:27:26 -0700 Subject: [PATCH 1/3] Spruced up the pomodoro module. Added icons/colors to the pomodoro module and shortened the display text. --- bumblebee/modules/pomodoro.py | 45 +++++++++------- themes/firefox-dark-powerline.json | 14 ++++- themes/greyish-powerline.json | 17 +++++- themes/gruvbox-light.json | 17 +++++- themes/gruvbox-powerline-light.json | 82 +++++++++++++++++------------ themes/gruvbox-powerline.json | 16 +++++- themes/gruvbox.json | 17 +++++- themes/iceberg-dark-powerline.json | 15 ++++++ themes/iceberg-powerline.json | 14 +++++ themes/iceberg-rainbow.json | 15 ++++++ themes/iceberg.json | 15 ++++++ themes/icons/ascii.json | 8 ++- themes/icons/awesome-fonts.json | 5 ++ themes/icons/ionicons.json | 6 +++ themes/onedark-powerline.json | 17 +++++- themes/powerline.json | 17 +++++- themes/sac_red.json | 17 +++++- themes/solarized-dark-awesome.json | 64 +++++++++++++--------- themes/solarized-powerline.json | 16 +++++- themes/solarized.json | 17 +++++- themes/wal-powerline.json | 17 +++++- 21 files changed, 361 insertions(+), 90 deletions(-) diff --git a/bumblebee/modules/pomodoro.py b/bumblebee/modules/pomodoro.py index 249ad2e..0eacc63 100644 --- a/bumblebee/modules/pomodoro.py +++ b/bumblebee/modules/pomodoro.py @@ -7,6 +7,7 @@ Right click will cancel the timer. from __future__ import absolute_import import datetime +from math import ceil import bumblebee.input import bumblebee.output @@ -15,12 +16,13 @@ import bumblebee.engine class Module(bumblebee.engine.Module): def __init__(self, engine, config): widgets = bumblebee.output.Widget(full_text=self.text) - self.remaining_time = datetime.timedelta(minutes=25) - self.remaining_time_str = "{}min{}s ".format(int((self.remaining_time.seconds / 60)), - round((self.remaining_time.seconds/60) % 1*60)) + self._work_period = 25 + self._play_period = 5 + self.remaining_time = datetime.timedelta(minutes=self._work_period) + self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60))) self.time = None - self.pomodoro = { "state":"OFF", "type": "n/a"} - self._text = self.remaining_time_str + self.pomodoro["type"] + " " + self.pomodoro["state"] + self.pomodoro = { "state":"OFF", "type": ""} + self._text = self.remaining_time_str + self.pomodoro["type"] super(Module, self).__init__(engine, config, widgets) engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self.timer_play_pause) @@ -38,21 +40,20 @@ class Module(bumblebee.engine.Module): self.time = datetime.datetime.now() if self.remaining_time.seconds <= 0: - if self.pomodoro["type"] == "WORK": - self.pomodoro["type"] = "PLAY" - self.remaining_time = datetime.timedelta(minutes=25) - elif self.pomodoro["type"] == "PLAY": - self.pomodoro["type"] = "WORK" - self.remaining_time = datetime.timedelta(minutes=5) + if self.pomodoro["type"] == "Work": + self.pomodoro["type"] = "Break" + self.remaining_time = datetime.timedelta(minutes=self._work_period) + elif self.pomodoro["type"] == "Break": + self.pomodoro["type"] = "Work" + self.remaining_time = datetime.timedelta(minutes=self._play_period) - 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.pomodoro["state"] + self.remaining_time_str = "{}m ".format(ceil((self.remaining_time.seconds / 60))) + self._text = self.remaining_time_str + self.pomodoro["type"] def timer_play_pause(self, widget): if self.pomodoro["state"] == "OFF": - self.pomodoro = {"state": "ON", "type": "WORK"} - self.remaining_time = datetime.timedelta(minutes=25) + self.pomodoro = {"state": "ON", "type": "Work"} + self.remaining_time = datetime.timedelta(minutes=self._work_period) self.time = datetime.datetime.now() elif self.pomodoro["state"] == "ON": self.pomodoro["state"] = "PAUSED" @@ -64,5 +65,13 @@ class Module(bumblebee.engine.Module): def timer_reset(self, widget): if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "PAUSED": - self.pomodoro = {"state":"OFF", "type": "n/a" } - self.remaining_time = datetime.timedelta(minutes=25) + self.pomodoro = {"state":"OFF", "type": "" } + self.remaining_time = datetime.timedelta(minutes=self._work_period) + + def state(self, widget): + state = []; + state.append(self.pomodoro["state"].lower()) + if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "OFF": + state.append(self.pomodoro["type"].lower()) + + return state diff --git a/themes/firefox-dark-powerline.json b/themes/firefox-dark-powerline.json index 4def35a..00e7d95 100644 --- a/themes/firefox-dark-powerline.json +++ b/themes/firefox-dark-powerline.json @@ -26,5 +26,17 @@ "fg": "#002b36", "bg": "#859900" } - } + }, + "pomodoro": { + "paused": { + "fg": "#002b36", + "bg": "#b58900" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } + + } diff --git a/themes/greyish-powerline.json b/themes/greyish-powerline.json index 1cbaaf6..2e9d9b8 100644 --- a/themes/greyish-powerline.json +++ b/themes/greyish-powerline.json @@ -42,5 +42,20 @@ "fg": "#002b36", "bg": "#859900" } - } + }, + "pomodoro": { + "paused": { + "fg": "#002b36", + "bg": "#b58900" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } + } diff --git a/themes/gruvbox-light.json b/themes/gruvbox-light.json index ebb7983..ee4d69e 100644 --- a/themes/gruvbox-light.json +++ b/themes/gruvbox-light.json @@ -54,5 +54,20 @@ "modified": { "bg": "#458588" }, "deleted": { "bg": "#9d0006" }, "new": { "bg": "#b16286" } - } + }, + "pomodoro": { + "paused": { + "fg": "#1d2021", + "bg": "#d79921" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } + } diff --git a/themes/gruvbox-powerline-light.json b/themes/gruvbox-powerline-light.json index ba4b441..d515df0 100644 --- a/themes/gruvbox-powerline-light.json +++ b/themes/gruvbox-powerline-light.json @@ -21,38 +21,52 @@ "fg": "#282828", "bg": "#fbf1c7" } - ], - "dnf": { - "good": { - "fg": "#002b36", - "bg": "#859900" - } - }, - "apt": { - "good": { - "fg": "#002b36", - "bg": "#859900" - } - }, - "battery": { - "charged": { - "fg": "#1d2021", - "bg": "#b8bb26" - }, - "AC": { - "fg": "#1d2021", - "bg": "#b8bb26" - } - }, - "bluetooth": { - "ON": { - "fg": "#1d2021", - "bg": "#b8bb26" - } - }, - "git": { - "modified": { "bg": "#458588" }, - "deleted": { "bg": "#9d0006" }, - "new": { "bg": "#b16286" } - } + ], + "dnf": { + "good": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "apt": { + "good": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "battery": { + "charged": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "AC": { + "fg": "#1d2021", + "bg": "#b8bb26" + } + }, + "bluetooth": { + "ON": { + "fg": "#1d2021", + "bg": "#b8bb26" + } + }, + "git": { + "modified": { "bg": "#458588" }, + "deleted": { "bg": "#9d0006" }, + "new": { "bg": "#b16286" } + }, + "pomodoro": { + "paused": { + "fg": "#1d2021", + "bg": "#d79921" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } } diff --git a/themes/gruvbox-powerline.json b/themes/gruvbox-powerline.json index 1e0f588..3481dbc 100644 --- a/themes/gruvbox-powerline.json +++ b/themes/gruvbox-powerline.json @@ -54,5 +54,19 @@ "modified": { "bg": "#458588" }, "deleted": { "bg": "#9d0006" }, "new": { "bg": "#b16286" } - } + }, + "pomodoro": { + "paused": { + "fg": "#1d2021", + "bg": "#d79921" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } } diff --git a/themes/gruvbox.json b/themes/gruvbox.json index 8ef2813..ab71814 100644 --- a/themes/gruvbox.json +++ b/themes/gruvbox.json @@ -54,5 +54,20 @@ "modified": { "bg": "#458588" }, "deleted": { "bg": "#9d0006" }, "new": { "bg": "#b16286" } - } + }, + "pomodoro": { + "paused": { + "fg": "#1d2021", + "bg": "#d79921" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } + } diff --git a/themes/iceberg-dark-powerline.json b/themes/iceberg-dark-powerline.json index 81af90e..1b13b84 100644 --- a/themes/iceberg-dark-powerline.json +++ b/themes/iceberg-dark-powerline.json @@ -47,5 +47,20 @@ "fg": "#0f1117", "bg": "#84a0c6" } + }, + "pomodoro": { + "paused": { + "fg": "#0f1117", + "bg": "#e2a478" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#b4be82", + "bg": "#161821" + } } + } diff --git a/themes/iceberg-powerline.json b/themes/iceberg-powerline.json index f6af51b..c7dca23 100644 --- a/themes/iceberg-powerline.json +++ b/themes/iceberg-powerline.json @@ -46,5 +46,19 @@ "fg": "#0f1117", "bg": "#84a0c6" } + }, + "pomodoro": { + "paused": { + "fg": "#0f1117", + "bg": "#e2a478" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#89b8c2", + "bg": "#161821" + } } } diff --git a/themes/iceberg-rainbow.json b/themes/iceberg-rainbow.json index e8cef97..9c56af6 100644 --- a/themes/iceberg-rainbow.json +++ b/themes/iceberg-rainbow.json @@ -46,5 +46,20 @@ "fg": "#89b8c2", "bg": "#161821" } + }, + "pomodoro": { + "paused": { + "fg": "#e2a478", + "bg": "#c6c8d1" + }, + "work": { + "fg": "#89b8c2", + "bg": "#161821" + }, + "break": { + "fg": "#b4be82", + "bg": "#161821" + } } + } diff --git a/themes/iceberg.json b/themes/iceberg.json index 5739b83..9943eb4 100644 --- a/themes/iceberg.json +++ b/themes/iceberg.json @@ -40,5 +40,20 @@ "fg": "#89b8c2", "bg": "#161821" } + }, + "pomodoro": { + "paused": { + "fg": "#0f1117", + "bg": "#e2a478" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#89b8c2", + "bg": "#161821" + } } + } diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index 2084ca1..3b24f47 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -302,6 +302,10 @@ }, "system": { "prefix": "system" - } - + }, + "pomodoro": { + "off": { "prefix": "pom" }, + "paused": { "prefix": "||" }, + "on": { "prefix": " >" } + } } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index eb805d4..c2c6c11 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -222,5 +222,10 @@ }, "rss": { "prefix": "" + }, + "pomodoro": { + "off": { "prefix": "🍅" }, + "paused": { "prefix": "" }, + "on": { "prefix": "" } } } diff --git a/themes/icons/ionicons.json b/themes/icons/ionicons.json index 08f9927..9f7a116 100644 --- a/themes/icons/ionicons.json +++ b/themes/icons/ionicons.json @@ -185,5 +185,11 @@ }, "rss": { "prefix": "\uf1ea" + }, + "pomodoro": { + "off": { "prefix": "\uf24f" }, + "paused": { "prefix": "\uf210" }, + "on": { "prefix": "\uf488" } } + } diff --git a/themes/onedark-powerline.json b/themes/onedark-powerline.json index 03867c6..d0ca586 100644 --- a/themes/onedark-powerline.json +++ b/themes/onedark-powerline.json @@ -36,5 +36,20 @@ "fg": "#282C34", "bg": "#98C379" } - } + }, + "pomodoro": { + "paused": { + "fg": "#282C34", + "bg": "#E5C07B" + }, + "work": { + "fg": "#98C379", + "bg": "#282C34" + }, + "break": { + "fg": "#282C34", + "bg": "#98C379" + } + } + } diff --git a/themes/powerline.json b/themes/powerline.json index 02f21f6..b2b603d 100644 --- a/themes/powerline.json +++ b/themes/powerline.json @@ -43,5 +43,20 @@ "fg": "#494949", "bg": "#41db00" } - } + }, + "pomodoro": { + "paused": { + "fg": "#d75f00", + "bg": "#ffd700" + }, + "work": { + "fg": "#ffd700", + "bg": "#d75f00" + }, + "break": { + "fg": "#494949", + "bg": "#41db00" + } + } + } diff --git a/themes/sac_red.json b/themes/sac_red.json index fade76e..7f6be68 100644 --- a/themes/sac_red.json +++ b/themes/sac_red.json @@ -40,5 +40,20 @@ }, "cmus": { "bg": "#C42021" - } + }, + "pomodoro": { + "paused": { + "fg": "#FDFFFC", + "bg": "#B91372" + }, + "work": { + "fg": "#FDFFFC", + "bg": "#41EAD4" + }, + "break": { + "fg": "#FDFFFC", + "bg": "#011627" + } + } + } diff --git a/themes/solarized-dark-awesome.json b/themes/solarized-dark-awesome.json index 9ec45e2..7274dc7 100644 --- a/themes/solarized-dark-awesome.json +++ b/themes/solarized-dark-awesome.json @@ -21,29 +21,43 @@ }, "apt": { "good": { - "fg": "#002b36", - "bg": "#859900" - } - }, - "pacman": { - "good": { - "fg": "#002b36", - "bg": "#859900" - } - }, - "battery": { - "charged": { - "fg": "#002b36", - "bg": "#859900" - }, - "AC": { - "fg": "#002b36", - "bg": "#859900" - } - }, - "git": { - "modified": { "bg": "#2aa198" }, - "deleted": { "bg": "#d33682" }, - "new": { "bg": "#859900" } - } + "fg": "#002b36", + "bg": "#859900" + } + }, + "pacman": { + "good": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "battery": { + "charged": { + "fg": "#002b36", + "bg": "#859900" + }, + "AC": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "git": { + "modified": { "bg": "#2aa198" }, + "deleted": { "bg": "#d33682" }, + "new": { "bg": "#859900" } + }, + "pomodoro": { + "paused": { + "fg": "#002b36", + "bg": "#b58900" + }, + "work": { + "fg": "#eee8d5", + "bg": "#586e75" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } } diff --git a/themes/solarized-powerline.json b/themes/solarized-powerline.json index 3e52f7f..25854f5 100644 --- a/themes/solarized-powerline.json +++ b/themes/solarized-powerline.json @@ -47,5 +47,19 @@ "modified": { "bg": "#2aa198" }, "deleted": { "bg": "#d33682" }, "new": { "bg": "#859900" } - } + }, + "pomodoro": { + "paused": { + "fg": "#002b36", + "bg": "#b58900" + }, + "work": { + "fg": "#eee8d5", + "bg": "#586e75" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } } diff --git a/themes/solarized.json b/themes/solarized.json index 4486634..e6f0082 100644 --- a/themes/solarized.json +++ b/themes/solarized.json @@ -49,5 +49,20 @@ "modified": { "bg": "#2aa198" }, "deleted": { "bg": "#d33682" }, "new": { "bg": "#859900" } - } + }, + "pomodoro": { + "paused": { + "fg": "#002b36", + "bg": "#b58900" + }, + "work": { + "fg": "#eee8d5", + "bg": "#586e75" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + } + } diff --git a/themes/wal-powerline.json b/themes/wal-powerline.json index dcb4fa9..8b28d3a 100644 --- a/themes/wal-powerline.json +++ b/themes/wal-powerline.json @@ -44,5 +44,20 @@ "fg": "background", "bg": "color3" } - } + }, + "pomodoro": { + "paused": { + "fg": "cursor", + "bg": "color6" + }, + "work": { + "fg": "background", + "bg": "foreground" + }, + "break": { + "fg": "background", + "bg": "color3" + } + } + } From c4ba2195b311b4a540048386fdc2c256ced843cd Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Sun, 29 Sep 2019 13:57:46 -0700 Subject: [PATCH 2/3] Changed Pomodoro icons, made the work/break periods variables --- bumblebee/modules/pomodoro.py | 18 +++++++++++------- themes/icons/awesome-fonts.json | 5 +++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/bumblebee/modules/pomodoro.py b/bumblebee/modules/pomodoro.py index 0eacc63..68909d9 100644 --- a/bumblebee/modules/pomodoro.py +++ b/bumblebee/modules/pomodoro.py @@ -16,10 +16,12 @@ import bumblebee.engine class Module(bumblebee.engine.Module): def __init__(self, engine, config): widgets = bumblebee.output.Widget(full_text=self.text) - self._work_period = 25 - self._play_period = 5 - self.remaining_time = datetime.timedelta(minutes=self._work_period) + self.work_period = 25 + self.break_period = 5 + 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 = "{}min{}s ".format(int((self.remaining_time.seconds / 60)), + # round((self.remaining_time.seconds/60) % 1*60)) self.time = None self.pomodoro = { "state":"OFF", "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.pomodoro["type"] == "Work": 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": 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 = "{}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"] def timer_play_pause(self, widget): if self.pomodoro["state"] == "OFF": 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() elif self.pomodoro["state"] == "ON": self.pomodoro["state"] = "PAUSED" @@ -66,7 +70,7 @@ class Module(bumblebee.engine.Module): def timer_reset(self, widget): if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "PAUSED": 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): state = []; diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index c2c6c11..d5e947f 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -224,8 +224,9 @@ "prefix": "" }, "pomodoro": { - "off": { "prefix": "🍅" }, + "off": { "prefix": "" }, "paused": { "prefix": "" }, - "on": { "prefix": "" } + "work": { "prefix": "" }, + "break": { "prefix": "" } } } From b107623f7abcc3fa51db81eada25179e75977c90 Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Mon, 30 Sep 2019 13:32:03 -0700 Subject: [PATCH 3/3] Added parameters for display format, work/break periods and notify --- bumblebee/modules/pomodoro.py | 70 +++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/bumblebee/modules/pomodoro.py b/bumblebee/modules/pomodoro.py index 68909d9..64f1514 100644 --- a/bumblebee/modules/pomodoro.py +++ b/bumblebee/modules/pomodoro.py @@ -3,6 +3,14 @@ """Display and run a Pomodoro timer. Left click to start timer, left click again to pause. Right click will cancel the timer. + +Parameters: + * pomodoro.work: The work duration of timer in minutes (defaults to 25) + * pomodoro.break: The break duration of timer in minutes (defaults to 5) + * pomodoro.format: Timer display format with "%m" and "%s" for minutes and seconds (defaults to "%m:%s") + Examples: "%m min %s sec", "%mm", "", "timer" + * pomodoro.notify: Notification command to run when timer ends/starts (defaults to nothing) + Example: 'notify-send "Time up!"' """ from __future__ import absolute_import @@ -16,21 +24,49 @@ import bumblebee.engine class Module(bumblebee.engine.Module): def __init__(self, engine, config): widgets = bumblebee.output.Widget(full_text=self.text) - self.work_period = 25 - self.break_period = 5 - 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 = "{}min{}s ".format(int((self.remaining_time.seconds / 60)), - # round((self.remaining_time.seconds/60) % 1*60)) + + super(Module, self).__init__(engine, config, widgets) + + # Parameters + self._work_period = int(self.parameter("work", 25)) + self._break_period = int(self.parameter("break", 5)) + self._time_format = self.parameter("format", "%m:%s") + self._notify_cmd = self.parameter("notify", "") + + # TODO: Handle time formats more gracefully. This is kludge. + self.display_seconds_p = False + self.display_minutes_p = False + if "%s" in self._time_format: + self.display_seconds_p = True + if "%m" in self._time_format: + self.display_minutes_p = True + + self.remaining_time = datetime.timedelta(minutes=self._work_period) + self.time = None self.pomodoro = { "state":"OFF", "type": ""} - self._text = self.remaining_time_str + self.pomodoro["type"] - super(Module, self).__init__(engine, config, widgets) + self._text = self.remaining_time_str() + self.pomodoro["type"] + engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self.timer_play_pause) engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd=self.timer_reset) + def remaining_time_str(self): + + if self.display_seconds_p and self.display_minutes_p: + minutes, seconds = divmod(self.remaining_time.seconds, 60) + if not self.display_seconds_p: + minutes = ceil(self.remaining_time.seconds / 60) + seconds = 0 + if not self.display_minutes_p: + minutes = 0 + seconds = self.remaining_time.seconds + + minutes = "{:2d}".format(minutes) + seconds = "{:02d}".format(seconds) + return self._time_format.replace("%m",minutes).replace("%s",seconds)+" " + def text(self, widget): return "{}".format(self._text) @@ -42,22 +78,24 @@ class Module(bumblebee.engine.Module): self.time = datetime.datetime.now() if self.remaining_time.seconds <= 0: + self.notify() if self.pomodoro["type"] == "Work": self.pomodoro["type"] = "Break" - self.remaining_time = datetime.timedelta(minutes=self.break_period) + self.remaining_time = datetime.timedelta(minutes=self._break_period) elif self.pomodoro["type"] == "Break": self.pomodoro["type"] = "Work" - 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 = "{}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 notify(self): + if self._notify_cmd: + bumblebee.util.execute(self._notify_cmd) + def timer_play_pause(self, widget): if self.pomodoro["state"] == "OFF": 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() elif self.pomodoro["state"] == "ON": self.pomodoro["state"] = "PAUSED" @@ -70,7 +108,7 @@ class Module(bumblebee.engine.Module): def timer_reset(self, widget): if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "PAUSED": 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): state = [];