Created
February 8, 2021 14:25
-
-
Save samuelantonioli/1c8d571f4103fb7109de5f9733bd286f to your computer and use it in GitHub Desktop.
mac-notification.py
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
import os | |
def notify(title, msg = ''): | |
'''small osascript notification with proper quotes escaping. don't use this with user input!''' | |
clean_str = lambda x: x.replace('"', '\\"').replace('\'', '\'\\\'\'') | |
os.system('osascript -e \'display notification "{}" with title "{}"\''.format( | |
clean_str(msg), | |
clean_str(title) | |
)) | |
notify('Test - "Tiffany\'s Donut Store"', '"Whatever, Bernard" - Tiffany') | |
# osascript -e 'display notification "hello world!" with title "This is the title"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment