Last active
August 8, 2018 20:04
-
-
Save catichenor/b707de786ebb1bdd7c6d56cb881864c7 to your computer and use it in GitHub Desktop.
Simple Pomodoro timer, this time for Mac.
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/python | |
| # Work for 25 minutes, break for 5 minutes. | |
| # Thanks to lukaszb for the gist at https://gist.github.com/lukaszb/5001170 | |
| import time | |
| from datetime import datetime | |
| from Foundation import NSUserNotification | |
| from Foundation import NSUserNotificationCenter | |
| def create_notification(title, message): | |
| notification = NSUserNotification.alloc().init() | |
| notification.setTitle_(title) | |
| notification.setInformativeText_(message) | |
| center = NSUserNotificationCenter.defaultUserNotificationCenter() | |
| center.deliverNotification_(notification) | |
| 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__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment