I’m not keen on having the system power state controlled by the lid for a few reasons:
- I often wish to use it on AC power with the lid closed and a USB keyboard connected. This is fine with the default settings but also….
- I don’t like having the controls act differently depending on the power state – particularly, if the mains goes away, I don’t want the system to act differently to how I expect (eg unexpectedly go to sleep during a power cut).
- The lid sensor is a magnet, which means that a magnetic field or magnetized object nearby might wake the laptop while I am transporting it, resulting in possible heat damage and unexpected flat battery.
- The same might happen if the laptop is jostled, for example by a bumpy journey.
Completely disabling this behaviour requires a few steps.
First of all, we need to disable “sleep on lid close”:
- With systemd in control (the “modern” way) – edit /etc/systemd/logind.conf and set all the relevant ‘handle’ lines to ‘ignore’.
- With acpid (the “legacy” way) – edit the relevant file in /etc/acpi/actions.
- If you’re using a desktop environment like GNOME, use its tools (if any) to disable sleep on lid close.
The next part is to disable “wake on lid open”. There’s no pretty GUI tool for this:
- echo ” LID” > /proc/acpi/wakeup (note the space between the first ” and the word LID)
- Once you’re happy that it works, add that line to /etc/rc.local.