Small addition: I just found out there has to be a way to fetch events from powerd! it is in the file /usr/share/webkit-1.0/pillow/javascripts/simple_alert_config.js
I hope I get this soon.
EDIT:
Found out the command and syntax!
Code:
nativeBridge.subscribeToEvent(appID, appEvent)
where appID is "com.lab126.powerd" and appEvent is for example "outOfScreenSaver"
Now I only have to find out how to catch this