sleepwatcher

Monitors Mac sleep, wakeup, and idle events to trigger custom actions

brewmacoslinux
Try with needOr install directly
Source

About

Monitors sleep, wakeup, and idleness of a Mac

Commands

sleepwatcher

Examples

Monitor sleep events and run a script when Mac goes to sleep$ sleepwatcher -s ~/.sleep
Monitor wakeup events and run a script when Mac wakes up$ sleepwatcher -w ~/.wakeup
Monitor idle state with 60 second timeout and run script when idle$ sleepwatcher -i 60 -b ~/.idle