Currently the preRun script is executed in pre_sleep_activity(), but its exit code is ignored, so sleep always continues.
It would be useful if a non-zero exit status could prevent sleep until the next scheduled run/check.
Something like this may work:
pre_sleep_activity() {
...
if [[ -x $preRun ]]; then
log "Execute custom commands before sleep"
if ! "$preRun"; then
log "Pre-sleep script returned a failure status. Aborting sleep."
return 1
fi
fi
system_sleep() {
# Do pre-sleep activities
if ! pre_sleep_activity; then
log "Sleep cancelled by pre-sleep script."
return 1
fi
...
Currently the preRun script is executed in pre_sleep_activity(), but its exit code is ignored, so sleep always continues.
It would be useful if a non-zero exit status could prevent sleep until the next scheduled run/check.
Something like this may work: