-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpomodoro.py
More file actions
executable file
·52 lines (41 loc) · 1.54 KB
/
pomodoro.py
File metadata and controls
executable file
·52 lines (41 loc) · 1.54 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
import time
import argparse
import subprocess
soundpath = "/home/nuvhandra/Music/tibet/bowl.wav"
def playsound():
sproc = subprocess.Popen(['cvlc','--play-and-exit', soundpath], close_fds=True)
time.sleep(20)
sproc.kill()
def pomodoro_timer(work_time, short_break, long_break):
work_time *= 60
short_break *= 60
long_break *= 60
pomodoro_count = 0
print("Pomodoro Timer")
while True:
print(f"Work for {work_time/60} minutes")
subprocess.Popen(['notify-send',f"Work for {work_time/60} minutes",'--expire-time=10000'])
playsound()
for _ in range(work_time-20):
time.sleep(1)
pomodoro_count += 1
if pomodoro_count % 4 == 0:
print(f"Take a {long_break/60}-minute break")
subprocess.Popen(['notify-send',f"Take a {long_break/60}-minute break",'--expire-time=10000'])
playsound()
for _ in range(long_break-20):
time.sleep(1)
else:
print(f"Take a {short_break/60}-minute break")
subprocess.Popen(['notify-send',f"Take a {short_break/60}-minute break",'--expire-time=10000'])
playsound()
for _ in range(short_break-20):
time.sleep(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Pomodoro Timer')
parser.add_argument('--work_time', type=int, default=25, help='Work time in minutes')
parser.add_argument('--short_break', type=int, default=5, help='Short break time in minutes')
parser.add_argument('--long_break', type=int, default=15, help='Long break time in minutes')
args = parser.parse_args()
pomodoro_timer(args.work_time, args.short_break, args.long_break)