I have a weird problem where my laptop will wake when it's closed, generating a lot of heat and causing much frustration.

Is there a way that I can tell if the laptop's lid is closed so that I can automatically suspend the computer (via a cron script) if it wakes itself while the lid is closed?

Closing the lid does currently suspend the machine and opening it does wake it, so that works properly. It's a 2011 MacBook Pro running Ubuntu 12.04.

  • I'm having a similar issue with a Dell laptop running Arch Linux.
    – cjm
    Aug 3, 2014 at 22:30

2 Answers 2


For my specific case, I can get the status of the lid with

$ cat /proc/acpi/button/lid/LID0/state
state:    open

I can then just grep for open or closed to see if it's open or closed.

  • To note: this works on my MacBook Pro, a Dell laptop, and a Gateway laptop also, so I'm assuming this is fairly ubiquitous. Aug 6, 2014 at 21:50
  • How about 2 in 1 notebooks that can have lid 360° opened? is there an indication or should we use some combination of lid open and accelerometer readings?
    – JrBenito
    Apr 24, 2017 at 21:00
  • Answering to my own comment, I put hands on 2 in 1 (Dell) and it only reports "open/close". However, when computer goes tablet or tent mode there is a keystroke reported to disable keyboard, hence, a combination of accel, keystroke and lid "open/close" can tell if the computer is in tablet/tent mode.
    – JrBenito
    Apr 25, 2017 at 12:37

Not really an answer to your linux-specific question, so maybe this answer should be moved to the comments:

MacBooks of all generations are known to have some issues with their system management controller of which one of the symptoms is strange behavior on lid-close and lid-open. This support page from Apple might help you resolve the problem: https://support.apple.com/kb/HT3964

  • BSD-style systems usually have a sysctl value that indicates whether the lid is open or closed. sysctl | grep lid would yield the name of the sysctl you want. However, I don't know about the way Linux handles this.
    – user79620
    Aug 3, 2014 at 23:19

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.