Recently, I assembled a NAS system using an old laptop and needed to configure it so that the laptop does not enter sleep mode when the lid is closed. Here are the steps I followed:
- Edit the logind.conf file with the following command:
vi /etc/systemd/logind.conf
- You will see the following content:
#HandlePowerKey: Action when the power button is pressed, default is power off
#HandleSleepKey: Action when the sleep button is pressed, default is suspend
#HandleHibernateKey: Action when the hibernate button is pressed, default is hibernate
#HandleLidSwitch: Action when the laptop lid is closed, default is suspend (HandleLidSwitch=lock)Note: Change the last parameter of HandleLidSwitch to lock and remove the preceding comment #.
- To make the changes take effect immediately, enter the command:
systemctl restart systemd-logind
- Done! The laptop lid will no longer cause it to enter sleep mode.