For those who want it automatic shutdown, hibernate, or do nothing when laptop lid is closed, here’s how to do it by hacking on the configuration file.
1. Open terminal by pressing Ctrl+Alt+T or searching for “Terminal” from start menu. When it opens, run command:
sudo gedit /etc/systemd/logind.conf
Type in your password (no visual feedback while typing due to security reason) when prompts and hit Enter to continue.
2. When the files opens, uncomment the line #HandleLidSwitch=suspend by removing # in the beginning, and change the value to:
- HandleLidSwitch=poweroff, shutdown / power off when lid is closed.
- HandleLidSwitch=hibernate, hibernate when lid is closed (need to test if hibernate works).
- HandleLidSwitch=ignore, do nothing.
- HandleLidSwitch=suspend, suspend laptop when lid is closed.
Save the file and finally restart the Systemd service to apply changes via command:
systemctl restart systemd-logind.service
1. Previous steps do not add shutdown or hibernate options in the Power settings utility, but directly do the action when you close the laptop lid.
2. For some laptops, the hibernate function might not work. Run test command:
sudo apt install pm-utils && sudo pm-hibernate
After your computer turns off, switch it back on. Did previous opened applications re-open? If hibernate doesn’t work, check if your swap partition is at least as large as your available RAM.