diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d39431..22ab930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v9? - We have moved the root check to the beginning of the script, and improved DEBUG handling with two different modes. `DEBUG=0` is still for production, and `1` is still for the DEBUG we previously knew downloading to the directory it is running from, but `2` will download to temporary folder, will detect updates, but will not install anything, but it will notify the user (almost as running the script without root before). +- Added option to not interrupt Do Not Disturb full screen apps like Keynote or Zoom with `INTERRUPT_DND="no"`. Default is `"yes"` which is how it has worked until now. - `pkgName` in a label can now be searched for. An example is logitechoptions, where only the name of the pkg is given, and not the exact file path to it. - `LSMinimumSystemVersion` will now be honered, if the `Info.plist` in the app is specifying this. That means that an app that has this parameter in that file and it shows that the app requires a newer version of the OS than is currently installed, then we will not install it. - New variable `RETURN_LABEL_NAME`. If given the value `1`, like `RETURN_LABEL_NAME=1` then Installomator only returns the name of the label. It makes for a better user friendly message for displaying in DEPNotify if that is integrated. @@ -20,6 +21,7 @@ Big changes to logging: - A function to shorten duplicate lines in installation logs or output of longer commands - Ability to extract install.log in the time when Installomator was running, if further investigations needs to be done to logs + ## v8.0 - removed leading `0` from the version because it has lost all meaning (thanks to @grahampugh for the inspiration) diff --git a/fragments/functions.sh b/fragments/functions.sh index 8b703f7..647ef85 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -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 +} diff --git a/fragments/header.sh b/fragments/header.sh index 9dbb81e..25dfaf4 100644 --- a/fragments/header.sh +++ b/fragments/header.sh @@ -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. diff --git a/fragments/main.sh b/fragments/main.sh index 557b35b..f77335f 100644 --- a/fragments/main.sh +++ b/fragments/main.sh @@ -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}"