From time to time (maybe a couple of times a week) when I get to my computer (a Macbook Pro) expecting it to be asleep with the lid closed the fans are running
Most of the time it is a Chrome process or Thunderbird that is eating up all the CPU on one core that causes this.
I assume is is the power nap feature that allows this to happen and I don't want to disable that.
Instead I would like to execute a script that could send a kill -STOP or similar to any PID that has used more than X seconds of CPU time since I closed the lid last time.
(And then preferably a kill -CONT when I open the lid).
I could use sleepwatcher to execute the script when the lid closes/opens.
Any ready made solutions for this purpose?