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:

while sleep 1; do
    grep 'closed' /proc/acpi/button/lid/LID0/state && beep

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

  • Show the script please, I'm curious how you did it. – wie5Ooma Feb 16 '16 at 22:58
  • It's a big python script doing a few other irelevant tasks and I'm afraid you'll get lost (I'm not proud of its quality either). Anyway you only need a grep 'closed' /proc/acpi/button/lid/LID0/state to check if the lid is closed. So if for a few dozen seconds your script keeps finding the lid closed it should take action – ndemou Feb 17 '16 at 8:45

Long answer short: put the laptop into shutdown/hibernate mode whilst in a backpack.

No need to worry about overheating.

  • 2
    Yeah... It's all about when system fails to turn itself off and you don't notice that. – ViliusK Feb 21 '15 at 7:51
  • Maybe try a modified version/keysequence of alt+sysrq+reisub before putting the laptop in the backpack, but instead of rebooting, make the sequence shutdown. – user371765 Feb 21 '15 at 8:15
  • Closing the lid for suspending is just fine for me. :) but it leaves me with a little worry if it finished suspending. I want my Ubuntu be worry-free. I want it to let me know by beeping when suspending failed. :) – ViliusK Feb 21 '15 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.