Skip to content

Instantly share code, notes, and snippets.

@catichenor
Last active August 8, 2018 20:04
Show Gist options
  • Select an option

  • Save catichenor/b707de786ebb1bdd7c6d56cb881864c7 to your computer and use it in GitHub Desktop.

Select an option

Save catichenor/b707de786ebb1bdd7c6d56cb881864c7 to your computer and use it in GitHub Desktop.
Simple Pomodoro timer, this time for Mac.
#!/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