Skip to content

Instantly share code, notes, and snippets.

@JokerQyou
Forked from instagrim-dev/notify.py
Last active January 2, 2018 12:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JokerQyou/1a395c2a76adbc09dcb9 to your computer and use it in GitHub Desktop.
Save JokerQyou/1a395c2a76adbc09dcb9 to your computer and use it in GitHub Desktop.
A python lib for sending notification on OS X
# coding: utf-8
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
def notify(message, title='Notification', sound=False):
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setInformativeText_(message)
if sound:
notification.setSoundName_(NSUserNotificationDefaultSoundName)
center = NSUserNotificationCenter.defaultUserNotificationCenter()
center.deliverNotification_(notification)
if __name__ == '__main__':
notify('This is a notification test', title='Test script', sound=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment