Created
May 2, 2017 15:50
-
-
Save badstreff/2c013e4ac08edbc36148fbceec8a32bc to your computer and use it in GitHub Desktop.
This file contains 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 | |
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