power-management – How to Determine Status of Laptop Lid

laptoppower-management

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.

Best Answer

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.

Related Question