[modules/pomodoro] quotes
This commit is contained in:
parent
37f7492d75
commit
b36b37d94f
1 changed files with 32 additions and 32 deletions
|
@ -7,10 +7,10 @@ Right click will cancel the timer.
|
||||||
Parameters:
|
Parameters:
|
||||||
* pomodoro.work: The work duration of timer in minutes (defaults to 25)
|
* 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.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")
|
* pomodoro.format: Timer display format with '%m' and '%s' for minutes and seconds (defaults to '%m:%s')
|
||||||
Examples: "%m min %s sec", "%mm", "", "timer"
|
Examples: '%m min %s sec', '%mm', '', 'timer'
|
||||||
* pomodoro.notify: Notification command to run when timer ends/starts (defaults to nothing)
|
* pomodoro.notify: Notification command to run when timer ends/starts (defaults to nothing)
|
||||||
Example: 'notify-send "Time up!"'. If you want to chain multiple commands,
|
Example: 'notify-send 'Time up!''. If you want to chain multiple commands,
|
||||||
please use an external wrapper script and invoke that. The module itself does
|
please use an external wrapper script and invoke that. The module itself does
|
||||||
not support command chaining (see https://github.com/tobi-wan-kenobi/bumblebee-status/issues/532
|
not support command chaining (see https://github.com/tobi-wan-kenobi/bumblebee-status/issues/532
|
||||||
for a detailled explanation)
|
for a detailled explanation)
|
||||||
|
@ -31,24 +31,24 @@ class Module(bumblebee.engine.Module):
|
||||||
super(Module, self).__init__(engine, config, widgets)
|
super(Module, self).__init__(engine, config, widgets)
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
self._work_period = int(self.parameter("work", 25))
|
self._work_period = int(self.parameter('work', 25))
|
||||||
self._break_period = int(self.parameter("break", 5))
|
self._break_period = int(self.parameter('break', 5))
|
||||||
self._time_format = self.parameter("format", "%m:%s")
|
self._time_format = self.parameter('format', '%m:%s')
|
||||||
self._notify_cmd = self.parameter("notify", "")
|
self._notify_cmd = self.parameter('notify', '')
|
||||||
|
|
||||||
# TODO: Handle time formats more gracefully. This is kludge.
|
# TODO: Handle time formats more gracefully. This is kludge.
|
||||||
self.display_seconds_p = False
|
self.display_seconds_p = False
|
||||||
self.display_minutes_p = False
|
self.display_minutes_p = False
|
||||||
if "%s" in self._time_format:
|
if '%s' in self._time_format:
|
||||||
self.display_seconds_p = True
|
self.display_seconds_p = True
|
||||||
if "%m" in self._time_format:
|
if '%m' in self._time_format:
|
||||||
self.display_minutes_p = True
|
self.display_minutes_p = True
|
||||||
|
|
||||||
self.remaining_time = datetime.timedelta(minutes=self._work_period)
|
self.remaining_time = datetime.timedelta(minutes=self._work_period)
|
||||||
|
|
||||||
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']
|
||||||
|
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
||||||
cmd=self.timer_play_pause)
|
cmd=self.timer_play_pause)
|
||||||
|
@ -66,15 +66,15 @@ class Module(bumblebee.engine.Module):
|
||||||
minutes = 0
|
minutes = 0
|
||||||
seconds = self.remaining_time.seconds
|
seconds = self.remaining_time.seconds
|
||||||
|
|
||||||
minutes = "{:2d}".format(minutes)
|
minutes = '{:2d}'.format(minutes)
|
||||||
seconds = "{:02d}".format(seconds)
|
seconds = '{:02d}'.format(seconds)
|
||||||
return self._time_format.replace("%m",minutes).replace("%s",seconds)+" "
|
return self._time_format.replace('%m',minutes).replace('%s',seconds)+' '
|
||||||
|
|
||||||
def text(self, widget):
|
def text(self, widget):
|
||||||
return "{}".format(self._text)
|
return '{}'.format(self._text)
|
||||||
|
|
||||||
def update(self, widget):
|
def update(self, widget):
|
||||||
if self.pomodoro["state"] == "ON":
|
if self.pomodoro['state'] == 'ON':
|
||||||
timediff = (datetime.datetime.now() - self.time)
|
timediff = (datetime.datetime.now() - self.time)
|
||||||
if timediff.seconds >= 0:
|
if timediff.seconds >= 0:
|
||||||
self.remaining_time -= timediff
|
self.remaining_time -= timediff
|
||||||
|
@ -82,41 +82,41 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
if self.remaining_time.total_seconds() <= 0:
|
if self.remaining_time.total_seconds() <= 0:
|
||||||
self.notify()
|
self.notify()
|
||||||
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._break_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._work_period)
|
self.remaining_time = datetime.timedelta(minutes=self._work_period)
|
||||||
|
|
||||||
self._text = self.remaining_time_str() + self.pomodoro["type"]
|
self._text = self.remaining_time_str() + self.pomodoro['type']
|
||||||
|
|
||||||
def notify(self):
|
def notify(self):
|
||||||
if self._notify_cmd:
|
if self._notify_cmd:
|
||||||
bumblebee.util.execute(self._notify_cmd)
|
bumblebee.util.execute(self._notify_cmd)
|
||||||
|
|
||||||
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'
|
||||||
self.remaining_time -= (datetime.datetime.now() - self.time)
|
self.remaining_time -= (datetime.datetime.now() - self.time)
|
||||||
self.time = datetime.datetime.now()
|
self.time = datetime.datetime.now()
|
||||||
elif self.pomodoro["state"] == "PAUSED":
|
elif self.pomodoro['state'] == 'PAUSED':
|
||||||
self.pomodoro["state"] = "ON"
|
self.pomodoro['state'] = 'ON'
|
||||||
self.time = datetime.datetime.now()
|
self.time = datetime.datetime.now()
|
||||||
|
|
||||||
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 = [];
|
||||||
state.append(self.pomodoro["state"].lower())
|
state.append(self.pomodoro['state'].lower())
|
||||||
if self.pomodoro["state"] == "ON" or self.pomodoro["state"] == "OFF":
|
if self.pomodoro['state'] == 'ON' or self.pomodoro['state'] == 'OFF':
|
||||||
state.append(self.pomodoro["type"].lower())
|
state.append(self.pomodoro['type'].lower())
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
Loading…
Reference in a new issue