mirror of
https://github.com/mtan93/Installomator.git
synced 2026-04-01 14:23:06 +01:00
Merge branch 'pr/268' into 2022-02-02_Theile-base
This commit is contained in:
@@ -820,4 +820,30 @@ finishing() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Detect if there is an app actively making a display sleep assertion, e.g.
|
||||
# KeyNote, PowerPoint, Zoom, or Webex.
|
||||
# See: https://developer.apple.com/documentation/iokit/iopmlib_h/iopmassertiontypes
|
||||
hasDisplaySleepAssertion() {
|
||||
# Get the names of all apps with active display sleep assertions
|
||||
local apps="$(/usr/bin/pmset -g assertions | /usr/bin/awk '/NoDisplaySleepAssertion | PreventUserIdleDisplaySleep/ && match($0,/\(.+\)/) && ! /coreaudiod/ {gsub(/^.*\(/,"",$0); gsub(/\).*$/,"",$0); print};')"
|
||||
|
||||
if [[ ! "${apps}" ]]; then
|
||||
# No display sleep assertions detected
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Create an array of apps that need to be ignored
|
||||
local ignore_array=("${(@s/,/)IGNORE_DND_APPS}")
|
||||
|
||||
for app in ${(f)apps}; do
|
||||
if (( ! ${ignore_array[(Ie)${app}]} )); then
|
||||
# Relevant app with display sleep assertion detected
|
||||
printlog "Display sleep assertion detected by ${app}."
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# No relevant display sleep assertion detected
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,18 @@ REOPEN="yes"
|
||||
# instead of just the label name.
|
||||
|
||||
|
||||
# Interrupt Do Not Disturb (DND) full screen apps
|
||||
INTERRUPT_DND="yes"
|
||||
# options:
|
||||
# - yes Script will run without checking for DND full screen apps.
|
||||
# - no Script will exit when an active DND full screen app is detected.
|
||||
|
||||
# Comma separated list of app names to ignore when evaluating DND
|
||||
IGNORE_DND_APPS=""
|
||||
# example that will ignore browsers when evaluating DND:
|
||||
# IGNORE_DND_APPS="firefox,Google Chrome,Safari,Microsoft Edge,Opera,Amphetamine,caffeinate"
|
||||
|
||||
|
||||
# NOTE: How labels work
|
||||
|
||||
# Each workflow label needs to be listed in the case statement below.
|
||||
|
||||
@@ -15,6 +15,13 @@ fi
|
||||
|
||||
# MARK: application download and installation starts here
|
||||
|
||||
if [[ ${INTERRUPT_DND} = "no" ]]; then
|
||||
# Check if a fullscreen app is active
|
||||
if hasDisplaySleepAssertion; then
|
||||
cleanupAndExit 1 "active display sleep assertion detected, aborting"
|
||||
fi
|
||||
fi
|
||||
|
||||
printlog "BLOCKING_PROCESS_ACTION=${BLOCKING_PROCESS_ACTION}"
|
||||
printlog "NOTIFY=${NOTIFY}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user