Created
February 4, 2017 16:54
-
-
Save embayer/04511b124125fbaee98cba802509e5b2 to your computer and use it in GitHub Desktop.
use applescript to display a notification on macOS
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
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