in reply to Detecting idle time on Mac

man getloadavg
may help
Boris