Created
September 24, 2017 15:39
-
-
Save gniemetz/65c2e287024e3317afc91da34fb12f31 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 AppKit | |
import Foundation | |
def notify(title, subtitle, info_text, sound=False, appImage=None, contentImage=None, delay=0): | |
notification = Foundation.NSUserNotification.alloc().init() | |
notification.setTitle_(title) | |
notification.setSubtitle_(subtitle) | |
notification.setInformativeText_(info_text) | |
if appImage: | |
source_img = AppKit.NSImage.alloc().initByReferencingFile_(appImage) | |
notification.set_identityImage_(source_img) | |
if contentImage: | |
source_img = AppKit.NSImage.alloc().initByReferencingFile_(contentImage) | |
notification.setContentImage_(source_img) | |
if sound: | |
notification.setSoundName_("NSUserNotificationDefaultSoundName") | |
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date())) | |
Foundation.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification) | |
notify("Macbrained.org", "Python for the Bash Scripter", "Notify!", True ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment