Last active
July 25, 2022 16:58
-
-
Save catichenor/7e16b00aa3dd4ad4ba298e2acd1e9b23 to your computer and use it in GitHub Desktop.
Simple Pomodoro timer with Windows notifications
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
| #!/usr/bin/env python | |
| # ------ # | |
| # Requires notify-send: http://vaskovsky.net/notify-send/ | |
| # To link it to this script, download notify-send, | |
| # get the path of the `notify-send.exe` file, | |
| # and paste it into the "notify_send_path" variable. | |
| # ------ # | |
| # Work for 25 minutes, break for 5 minutes. | |
| from subprocess import Popen | |
| from datetime import datetime | |
| import time | |
| import sys | |
| import os | |
| notify_send_path = r'C:\path\to\notify-send.exe' | |
| # ^ Passing a raw string so the path doesn't have to be escaped. | |
| def create_notification(title, message): | |
| Popen([notify_send_path, | |
| title, | |
| message]) | |
| def get_time(): | |
| return(str(datetime.now().hour) + ":" + str(datetime.now().minute).zfill(2)) | |
| def main(): | |
| while True: | |
| print("Worktime: The time is " + get_time()) | |
| create_notification("Work", "Time to start working.") | |
| time.sleep(1200) | |
| print("Worktime: 5 minutes left. The time is " + get_time()) | |
| create_notification("Work", "5 minutes left.") | |
| time.sleep(300) | |
| print("Breaktime: The time is " + get_time()) | |
| create_notification("Break", "Time for a break.") | |
| time.sleep(300) | |
| if __name__ == '__main__': | |
| try: | |
| main() | |
| except KeyboardInterrupt: | |
| print('We got interrupted, time is {}'.format(datetime.now().strftime('%H:%M:%S'))) | |
| try: | |
| sys.exit(0) | |
| except SystemExit: | |
| os._exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment