Occasionally my laptop doesn't go to sleep when the lid is shut. The reasons for this vary, but it's often due to a driver that is in a bad state. I currently have no way of knowing there's a problem until hours later when I open the laptop and it's either fully drained the battery and hard powered off or the battery is severely depleted.
I'd like to create a rule such that for some predetermined log line or pattern an action is taken, such as running a script to generate an audible alert. Ideally this should be event based rather than polling, and if possible it would be good to avoid setting up a syslog configuration to achieve this.
Sample log lines for this include:
can't change power state from D3cold to D0 can't change power state from D3hot to D0