mirror of
https://github.com/munki/munki.git
synced 2026-05-07 12:59:32 -05:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user