diff --git a/main.py b/main.py index 23af100..88426f5 100755 --- a/main.py +++ b/main.py @@ -88,11 +88,11 @@ def wait_or_enter(duration, i3_focus=False): stderr=DEVNULL, ) - if stop: + if time() - start < duration: return sys.stdin.readline().strip() else: - print() tcflush(sys.stdin, TCIOFLUSH) + print(flush=True) return def write_break_message(msg): @@ -103,7 +103,6 @@ def write_break_message(msg): print(msg) f.write(msg + "\n") - def main(playlist, work_time, break_time): interval = generate_interval(work_time, break_time) while True: @@ -126,7 +125,6 @@ def main(playlist, work_time, break_time): write_break_message(msg) - def timer(playlist, duration): second = datetime.now().strftime("%H:%M:%S") print(second, "wait for", duration, "seconds") @@ -180,7 +178,7 @@ if __name__ == "__main__": if args.test_sound: test_playlist(args.playlist) - else: + elif args.once is None: # For some reason the first time I play the playlist it doesn't work. # This is a workaround. test_playlist(args.playlist, 10)