Skip to content

Instantly share code, notes, and snippets.

@albert-yu
Last active February 29, 2024 20:52
Show Gist options
  • Save albert-yu/71bc8a82ee965b1d401367081683164a to your computer and use it in GitHub Desktop.
Save albert-yu/71bc8a82ee965b1d401367081683164a to your computer and use it in GitHub Desktop.
Reminder to relax eyes every 20 minutes
import time
import os
def log_with_time(msg: str):
print("Time: {} - {}".format(time.strftime("%H:%M:%S"), msg))
def main():
iters = 0
cmd = input("Start? (y/n): ")
if cmd != "y":
return
while True:
log_with_time("20 minute timer started")
# sleep for 20 minutes
time.sleep(20 * 60)
# macOS only
os.system('say "Time to relax."')
# sleep for 20 seconds
time.sleep(20)
iters += 1
log_with_time("Iterations: {}".format(iters))
cmd = input("Continue? (y/n): ")
if cmd != "y":
log_with_time("Goodbye")
break
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment