-
Notifications
You must be signed in to change notification settings - Fork 4
/
timer.py
30 lines (22 loc) · 793 Bytes
/
timer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from time import sleep
from timeit import default_timer as timer
import click as click
from playsound import playsound
from rich.progress import Progress
_DEFAULT_TIME_SEC = 20 * 60
def getResourceDir():
ROOT_DIR = os.path.dirname(os.path.abspath(__file__).replace("./", ""))
return os.path.join(ROOT_DIR, "res")
@click.command()
@click.option("--time", default=_DEFAULT_TIME_SEC, help="time in second")
def startPomodoro(time):
with Progress() as progress:
task1 = progress.add_task("[green]Progress: ", total=time)
start = timer()
while not progress.finished:
progress.update(task1, completed=timer() - start)
sleep(1)
playsound(getResourceDir() + "/alarm.wav")
if __name__ == "__main__":
startPomodoro()