For laptop users, Ubuntu desktop only provide options “Suspend” and “Do Nothing” in its Power settings to act when the lid is closed.
If you want your laptop automatically shutdown or hibernate when you close the lid, just do below steps:
1. Open terminal from the Dash or by pressing Ctrl+Alt+T on keyboard. When it opens, run below command to edit the configuration file:
gksudo gedit /etc/systemd/logind.conf
Install gksu via Ubuntu Software Center if the command doesn’t work.
When the file opens, add one of below lines into the end and click save.
- HandleLidSwitch=hibernate – to hibernate when lid closed
- HandleLidSwitch=poweroff – to shutdown when lid closed
2. After saved the file, restart systemd-logind service to apply the changes. To do so, run command:
sudo service systemd-logind restart
Finally close your laptop lid and see effect.