A friend said, his laptop's battery is very weak after Ubuntu failed to suspend after lid closed. He then quickly put laptop to backpack and did not realized, that laptop is still working.
I'm wondering how to make Ubuntu beep when lid is closed for N minutes, but system is not suspended and temperature increased up to a danger zone?
UPDATE: Question here is how to make it warn me that it failed to switch off. If I'll be in a hurry I'm sure I will not want to wait 5s until I'll be sure it went off. I'll be closing the lid, throwing laptop into backpack and running. :)
I've written a script that counts seconds with the lid closed[1] and shutdowns the system after 1 minute. I've seen that every once in a few months my laptop will not go to suspend[2] and it will get REALLY hot inside my backpack and I'll get really sad/mad.
Anyway to answer your direct question here is a script that will beep every 1 second when lid is closed:
But I don't recommend you use it. The reason is that I've not found a reliable way to make a loud beep from a laptop (or most today’s desktops). And besides: what if you don't hear the beeps (your laptop is most likely inside a bag that protects it and suppresses audio output from it)? I suggest you just shutdown the system after one minute of beeps.
[1] I'm checking the contents of
/proc/acpi/button/lid/LID0/state
to find out if the lid is closed.[2] syslog will have a line stating that
Freezing of tasks failed after 20.xxx seconds
Long answer short: put the laptop into shutdown/hibernate mode whilst in a backpack.
No need to worry about overheating.