Created
January 5, 2020 20:10
-
-
Save benstigsen/0c575f79c950a2557a8358ad11f963e0 to your computer and use it in GitHub Desktop.
Pomodoro Windows timer (includes audio feedback)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, winsound, os | |
def clear(): | |
os.system("cls||clear") | |
def playTone(frequency, duration, repeat): | |
for _ in range(repeat): | |
winsound.Beep(frequency, duration) | |
def work(duration = 1200, text = "-"): | |
playTone(1300, 100, 2) | |
for (i) in range(10): | |
clear() | |
print(f"Work | {text} | {((duration / 10) * (10 - i)) / 60} minutes\n") | |
time.sleep(duration / 10) | |
def pause(duration = 300, text = "-"): | |
playTone(1000, 150, 3) | |
for (i) in range(10): | |
clear() | |
print(f"Break | ({text}) | {((duration / 10) * (10 - i)) / 60} minutes\n") | |
time.sleep(duration / 10) | |
def start(rounds, work_duration, break_duration): | |
while True: | |
for (i) in range(rounds): | |
work(duration = work_duration, text = f"{i + 1}/{rounds}") | |
if (i == rounds - 1): | |
# Long Break (5x short break duration) | |
pause(break_duration * 5) | |
else: | |
# Regular Break | |
pause(duration = break_duration, text = f"{i + 1}/{rounds}") | |
start(4, 1200, 300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment