In Ubuntu’s Power setting utility, you can only set to Suspend or Do nothing when your laptop lid is closed.
For those who want more lid closed hehavior, such as automatically Shutdown, Hibernate, or Restart, you can follow the steps below to enable either one by editing systemd config file.
1. Search for and install dconf Editor in Ubuntu Software. Then launch it and navigate to org -> gnome -> settings daemon -> plugins -> power.
Change the value of “lid-close-ac-action” and “lid-close-battery-action”.
Though it does not work for my laptop, I need to change the two values from “blank” to anything to make following steps work for me.
2. Open terminal from your app launcher or via Ctrl+Alt+T shortcut keys. When it opens, paste the command below and hit run:
sudo apt install gksu && gksudo gedit /etc/systemd/logind.conf
This command installs gksu
, allows graphical apps to ask user password to run program as root, and then open systemd config file via Gedit text editor.
3. When the file opens, as the following picture shows, uncomment the line #HandleLidSwitch=suspend and change its value to:
HandleLidSwitch=poweroff
– automatic shutdown when lid closed.HandleLidSwitch=hibernate
– automatic hibernate.HandleLidSwitch=ignore
– do nothing.
NOTE: The hibernate function is not enable by default in Ubuntu, you need to enable hibernation first before making Ubuntu auto-hibernate when lid is closed.
4. To apply changes, restart systemd service or restart your laptop.
systemctl restart systemd-logind.service
It does not add Shutdown and Hibernate options in your Power setting utility, but directly do the action after you made the change.