sudo sh <<"EOF" while sleep 1 do pgid="$(pgrep time)" state="$(ps ostate= "${pgid}" | grep -q 'T' && echo "stopped" || echo "running" )" temp="$(sysctl -n hw.acpi.thermal.tz1.temperature)" temp="${temp%%.*}" printf "\r %u %s " "${temp}" "${state}" if [ "${temp}" -ge 90 -a "${state}" == 'running' ] then echo "Stopping" kill -STOP -${pgid} fi if [ "${temp}" -le 70 -a "${state}" == 'stopped' ] then echo "Continuing" kill -CONT -${pgid} fi done EOF