Код: Выделить всё
WakeTracker.sh
Код: Выделить всё
#!/bin/bash
death_handler() {
echo "$(date) I am killed."
}
trap death_handler EXIT
echo "$(date) I am alive."
sleep 10d
< /code>
RunWhenUnlocked.sh
Код: Выделить всё
#!/bin/bash
cleanup() {
kill $child_pid
}
trap cleanup EXIT
block_until_lock() {
while [[ -z $(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null
Подробнее здесь: [url]https://stackoverflow.com/questions/79666179/is-there-a-non-polling-option-for-a-shell-script-to-block-until-the-macos-screen[/url]