Skip to content

Instantly share code, notes, and snippets.

@badstreff
Created May 2, 2017 15:50
Show Gist options
  • Save badstreff/2c013e4ac08edbc36148fbceec8a32bc to your computer and use it in GitHub Desktop.
Save badstreff/2c013e4ac08edbc36148fbceec8a32bc to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
from AppKit import NSImage
def main():
title = sys.argv[4]
message = sys.argv[5]
if len(sys.argv) > 6:
icon = sys.argv[6]
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setInformativeText_(message)
notification.setSoundName_(NSUserNotificationDefaultSoundName)
if icon:
image = NSImage.alloc().initWithContentsOfFile_(icon)
notification.set_identityImage_(image)
notification.set_identityImageHasBorder_(False)
center = NSUserNotificationCenter.defaultUserNotificationCenter()
center.deliverNotification_(notification)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment