Skip to content

Instantly share code, notes, and snippets.

@embayer
Created February 4, 2017 16:54
Show Gist options
  • Save embayer/04511b124125fbaee98cba802509e5b2 to your computer and use it in GitHub Desktop.
Save embayer/04511b124125fbaee98cba802509e5b2 to your computer and use it in GitHub Desktop.
use applescript to display a notification on macOS
def notify(title, subtitle, notification, soundname='Hero'):
''' use applescript to display a notification on macOS
'''
osascript_params = {
'title': title,
'subtitle': subtitle,
'soundname': soundname,
'notification': notification
}
osascript_cmd = '\'display notification \"{notification}\" with title \"{title}\" subtitle \"{subtitle}\" sound name \"{soundname}\"\''.format(**osascript_params)
cmd = 'osascript -e {}'.format(osascript_cmd)
run(cmd, shell=True, check=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment