-
Notifications
You must be signed in to change notification settings - Fork 0
/
pomo_cli.py
41 lines (31 loc) · 1.23 KB
/
pomo_cli.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
31
32
33
34
35
36
37
38
39
40
41
import argparse
from threading import Timer
import subprocess
import sys
parser = argparse.ArgumentParser(description='Pomodoro cli in python')
parser.add_argument('work', metavar='work_time', type=int, help='Working time in minutes')
parser.add_argument('rest', metavar='rest_time', type=int, help='Resting time in minutes')
parser.add_argument('-l', metavar='limit', type=int, help='Limit to pomodoros')
args = parser.parse_args()
pomo_done = 0
rest_time = args.rest * 60
work_time = args.work * 60
limit = args.l if args.l else 1000
def times_up(msg, sound):
sys.stdout.write("\033[F") # back to previous line
sys.stdout.write("\033[K")
sys.stdout.write(msg)
sys.stdout.flush()
subprocess.call(f"mpg123 -q /path/to/some/Sounds/{sound}.mp3", shell=True)
def do_pomo(pomo_done, work_time, rest_time):
work_msg = f'Pomodoros done: {pomo_done}\nWork work ' # added more spaces to overwrite the TIME word hacky
rest_msg = f'Pomodoros done: {pomo_done} \nYAY BREAK TIME'
work = Timer(work_time, times_up, args=(rest_msg, 'bell'))
work.start()
work.join()
rest = Timer(rest_time, times_up, args=(work_msg, 'fog'))
rest.start()
rest.join()
while pomo_done < limit:
pomo_done+=1
do_pomo(pomo_done, work_time, rest_time)