Skip user notification if a process has made a display sleep assertion, which may mean the user is 'presenting' or in a meeting

This commit is contained in:
Greg Neagle
2025-02-06 17:17:18 -08:00
parent 41e4a5cf89
commit f88d10eaef
2 changed files with 38 additions and 1 deletions
+21
View File
@@ -73,6 +73,7 @@ else:
from munkilib import munkistatus
from munkilib import osinstaller
from munkilib import osutils
from munkilib import powermgr
from munkilib import prefs
from munkilib import processes
from munkilib import reports
@@ -528,6 +529,19 @@ def sendEndNotification():
userInfo)
def activeDisplaySleepAssertion():
"""Returns a boolean to indicate we have an active assertion preventing
display sleep. Idea borrowed from Installomator."""
for processName, assertions in powermgr.getIOPMAssertions().items():
if (processName != "coreaudiod" and
("PreventUserIdleDisplaySleep" in assertions or
"NoDisplaySleepAssertion" in assertions)
):
munkilog.log("%s has an assertion preventing display sleep")
return True
return False
def notifyUserOfUpdates(force=False):
"""Notify the logged-in user of available updates.
@@ -562,6 +576,13 @@ def notifyUserOfUpdates(force=False):
# subtract 6 hours
interval = interval - (6 * 60 * 60)
nextNotifyDate = lastNotifiedDate.dateByAddingTimeInterval_(interval)
if activeDisplaySleepAssertion():
# display sleep assertions are made by Zoom during a meeting,
# PowerPoint and Keynote when presenting, and Chrome when playing
# a movie. Other apps may make these assertions as well, If we see
# such an assertion, don't notify this time.
munkilog.log("Skipping user notification.")
return False
if force or now.timeIntervalSinceDate_(nextNotifyDate) >= 0:
# record current notification date
prefs.set_pref('LastNotifiedDate', now)