Added option to not interrupt Do Not Disturb full screen apps like KeyNote or Zoom

This commit is contained in:
Raptor399
2021-10-12 12:14:29 +02:00
parent 4b53da0fb7
commit 9e2fa65670
4 changed files with 44 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
- Added bunch of new labels, and improved others.
- Renamed `buildCaseStatement.sh` to `buildLabel.sh` and improved it a lot. It is a great start when figuring out how to create a new label for an app, or a piece of software. Look at the tutorials in our wiki.
- Mosyle changed their app name from Business to Self-Service
- Added option to not interrupt Do Not Disturb full screen apps like KeyNote or Zoom with `INTERRUPT_DND="no"`.
## v0.6 - 2021-07-14

View File

@@ -616,4 +616,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
}

View File

@@ -102,6 +102,16 @@ REOPEN="yes"
# - no App not reopened
# 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="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.

View File

@@ -8,6 +8,13 @@ esac
# 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}"