Skip to content

Instantly share code, notes, and snippets.

@BenStigsen
Created January 5, 2020 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenStigsen/0c575f79c950a2557a8358ad11f963e0 to your computer and use it in GitHub Desktop.
Save BenStigsen/0c575f79c950a2557a8358ad11f963e0 to your computer and use it in GitHub Desktop.
Pomodoro Windows timer (includes audio feedback)
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