-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpom.py
40 lines (34 loc) · 1.74 KB
/
pom.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
import os
import time
from datetime import datetime, timedelta
import argparse
_myDir = os.path.abspath(os.path.dirname(__file__))
parser = argparse.ArgumentParser()
parser.add_argument('--sessions', '-s', type=int, default=4)
parser.add_argument('--work', '-w', type=int, default=25)
parser.add_argument('--rest', '-b', type=int, default=5) # 'break' is a Python keyword.
args = parser.parse_args()
sessions = args.sessions
session_dur = args.work
break_dur = args.rest
def do_pom(count, session_dur):
print(f'Session {count}/{sessions} started at {datetime.now().strftime("%-I:%M:%S %p")} and will end at {(datetime.now() + timedelta(minutes = session_dur)).strftime("%-I:%M:%S %p")}.')
time.sleep(session_dur * 60)
def do_break(count, break_dur):
os.system(f'''
osascript -e 'display dialog "{count} of {sessions} sessions completed." with title "Take a break!" with icon POSIX file "{_myDir}/images/break.icns" buttons {{"OK"}} default button 1'
''')
print(f'Break {count}/{sessions-1} started at {datetime.now().strftime("%-I:%M:%S %p")} and will end at {(datetime.now() + timedelta(minutes = break_dur)).strftime("%-I:%M:%S %p")}.')
time.sleep(break_dur * 60)
os.system(f'''
osascript -e 'display dialog "Starting session {count + 1} of {sessions}." with title "Get back to work!" with icon POSIX file "{_myDir}/images/work.icns" buttons {{"OK"}} default button 1'
''')
os.system('echo "Beginning pomodoro."')
for session in range(1, sessions + 1):
do_pom(session, session_dur)
if session < sessions:
do_break(session, break_dur)
else:
os.system(f'''
osascript -e 'display dialog "{session} of {sessions} sessions completed." with title "Congrats!" with icon POSIX file "{_myDir}/images/congrats.icns" buttons {{"OK"}} default button 1'
''')