Skip to content

Commit

Permalink
Merge pull request #179 from mattesno1/notifications-ignore-dnd
Browse files Browse the repository at this point in the history
allow notifications to be displayed in DND (e.g. screen sharing)
  • Loading branch information
daredoes committed Apr 8, 2022
2 parents 2d7e2f9 + 8b4879b commit d09e463
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rumps/notifications.py
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d09e463

Please sign in to comment.