Problem
I want to write a program in Python, where a script executes when it detects that it has been brought out of sleep mode. E.g I am using a laptop. When I open the laptop, the script should run. Is there a way to detect this and then run a script? Is there a module for listening for such events?
Goal
The ultimate goal is a sort of security system, where an alert is sent to a users phone, if their computer is used. I have an idea for the alert sending part, I just can't figure out how to trigger the program in the first place.
The basic format should look something like this:
if computer_active == True:
alert.send("Computer accessed")
Obviously it would look more complicated than that, but that's the general idea.
I'm running Python3.10.0 on MacOSX v10.15.7