Skip to content

Instantly share code, notes, and snippets.

@knowsuchagency knowsuchagency/notify
Last active Jul 5, 2018

What would you like to do?
A notification script for mac os
#!/usr/bin/env python3
import subprocess as sp
import argparse
import shlex
def notify(message: str, title='', subtitle='', sound=''):
Wraps osascript.
command = f"""osascript -e 'display notification "{message}" with title "{title}" subtitle "{subtitle}" sound name "{sound}"' """
def main():
"""Parse arguments from command line and pass to notify function."""
parser = argparse.ArgumentParser()
parser.add_argument('message', help="The body of the notification")
parser.add_argument('--title', help="The notification's title")
parser.add_argument('--subtitle', help="The notification's subtitle")
parser.add_argument('--sound', help="The sound the notification makes")
args = parser.parse_args()
notify(args.message, title=args.title, subtitle=args.subtitle, sound=args.sound)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.