Monday, February 15, 2021

Prevent CENTOS from putting laptop to sleep when closing the lid.

This will stop CENTOS from powering off, suspending, or knocking the network out if you close the lid of the laptop.

Some laptops can overheat if they are left running with the lid closed, especially if they are in a confined place like a backpack. Therefore, consider if changing the default setting (suspend) is the best option in your case.

  1. Open /etc/systemd/logind.conf file for editing.
  2. Find HandleLidSwitch=suspend line in the file. If it has a hash/pound (#) symbol, remove it. 
    Most instructions fail to mention that.  Very important.
    If the line is not present in the file, add it.

  3. Replace the default suspend parameter with one of the following:

    lock for the screen to lock
    poweroff for the computer to switch off
    ignore for nothing to happen

    Example:
    HandleLidSwitch=lock
  4. Save your changes and close the editor.
  5. Run the following command so that your changes preserve the next restart of the system:

    systemctl restart systemd-logind.service

2 comments:

Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.