11#!/usr/bin/python3
2+ # v0.3.0
23
34import sys
45import tkinter as tk
56import subprocess
67import os
78import datetime
89
9- version = "v0.2.0"
10-
1110fullpath = os .path .abspath (__file__ )
1211name_len = len (os .path .basename (__file__ ))
1312temppath = fullpath [:- name_len ]
1413
1514workmode_path = f"{ temppath } /workmode.txt"
1615addcron_path = f"{ temppath } /addcron.sh"
16+ sound_path = f"{ temppath } /sound.wav"
1717
18- def check_next (): #needs to return time to next in minutes
18+ def check_next ():
1919 current_crontab = subprocess .check_output (['crontab' ,'-l' ])
2020 current_crontab = current_crontab .decode ('utf-8' )
2121 correct_entry = ""
@@ -31,7 +31,7 @@ def check_next(): #needs to return time to next in minutes
3131 second_time = correct_entry .split (',' )[1 ]
3232 second_time = int (second_time )
3333 if current_time > first_time and current_time > second_time :
34- return first_time - current_time
34+ return 60 - current_time + first_time
3535 elif current_time >= first_time and current_time < second_time :
3636 return second_time - current_time
3737 elif current_time <= first_time and current_time < second_time :
@@ -82,9 +82,20 @@ def check_next(): #needs to return time to next in minutes
8282 with open (workmode_path ,"r" ) as file_read :
8383 mode = file_read .readlines ()[0 ]
8484 if mode == "set" :
85+ os_type = subprocess .check_output (['uname' ])
86+ os_type = os_type .decode ('utf-8' ).strip ("\n " )
87+ process = None
88+ if os_type == "Darwin" :
89+ process = subprocess .Popen (['afplay' ,sound_path ])
90+ elif os_type == "Linux" :
91+ process = subprocess .Popen (['aplay' ,sound_path ])
92+ else :
93+ print ("Your OS is not yet supported." )
8594 root = tk .Tk ()
86- root .geometry ("400x0 " )
95+ root .geometry ("400x100 " )
8796 root .attributes ("-topmost" , True )
8897 root .eval ('tk::PlaceWindow . center' )
8998 root .title ("TAKE A BREAK!" )
9099 root .mainloop ()
100+ if process :
101+ process .terminate ()
0 commit comments