From 8b4879b9dccbae07b2d92270011ebba7928463f5 Mon Sep 17 00:00:00 2001 From: Daniel Dammermann Date: Fri, 4 Feb 2022 12:23:52 +0000 Subject: [PATCH] allow notifications to be displayed in DND (e.g. screen sharing) --- rumps/notifications.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rumps/notifications.py b/rumps/notifications.py index 64c61cd..b111e50 100644 --- a/rumps/notifications.py +++ b/rumps/notifications.py @@ -129,7 +129,7 @@ def _clicked(ns_user_notification_center, ns_user_notification): def notify(title, subtitle, message, data=None, sound=True, action_button=None, other_button=None, has_reply_button=False, - icon=None): + icon=None, ignoreDnD=False): """Send a notification to Notification Center (OS X 10.8+). If running on a version of macOS that does not support notifications, a ``RuntimeError`` will be raised. Apple says, @@ -151,6 +151,8 @@ def notify(title, subtitle, message, data=None, sound=True, :param has_reply_button: whether or not the notification has a reply button. :param icon: the filename of an image for the notification's icon, will replace the default. + :param ignoreDnD: whether the notification should ignore do not disturb, + e.g., appear also while screen sharing. """ from . import rumps @@ -185,6 +187,8 @@ def notify(title, subtitle, message, data=None, sound=True, notification.set_showsButtons_(True) if has_reply_button: notification.setHasReplyButton_(True) + if ignoreDnD: + notification.set_ignoresDoNotDisturb_(True) notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date())) notification_center = _default_user_notification_center()