Pomodoro Notifications

This commit is contained in:
PrabhuUdurg 2023-10-02 22:51:36 +02:00
parent 3bc3c75ff4
commit 7d8c05bd69
2 changed files with 16 additions and 6 deletions

Binary file not shown.

View file

@ -15,6 +15,8 @@ Parameters:
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 detailed explanation) for a detailed explanation)
If you want to change the work and break duration, just change variables in the beginning of the pomodoro.py file.
contributed by `martindoublem <https://github.com/martindoublem>`_, inspired by `karthink <https://github.com/karthink>`_ - many thanks! contributed by `martindoublem <https://github.com/martindoublem>`_, inspired by `karthink <https://github.com/karthink>`_ - many thanks!
""" """
@ -25,17 +27,22 @@ from math import ceil
import core.module import core.module
import core.widget import core.widget
import core.input import core.input
import simpleaudio as sa
import util.cli import util.cli
# Recommended to use .wav format
sound= "/.config/i3/bumblebee-status/bumblebee_status/modules/contrib/pomodoro-sound.wav"
work_time = 25
break_time = 5
class Module(core.module.Module): class Module(core.module.Module):
def __init__(self, config, theme): def __init__(self, config, theme):
super().__init__(config, theme, core.widget.Widget(self.text)) super().__init__(config, theme, core.widget.Widget(self.text))
# Parameters # Parameters
self.__work_period = int(self.parameter("work", 25)) self.__work_period = int(self.parameter("work", work_time))
self.__break_period = int(self.parameter("break", 5)) self.__break_period = int(self.parameter("break", break_time))
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", "")
@ -96,8 +103,11 @@ class Module(core.module.Module):
self.__text = self.remaining_time_str() + self.pomodoro["type"] self.__text = self.remaining_time_str() + self.pomodoro["type"]
def notify(self): def notify(self):
wave = sa.WaveObject.from_wave_file(sound)
play = wave.play()
if self.__notify_cmd: if self.__notify_cmd:
util.cli.execute(self.__notify_cmd) util.cli.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":