Ubuntu 16.10: Auto Shutdown / Hibernate When Lid Closed

Ubuntu Laptop Lid behavior

For those running Ubuntu 16.10 on laptops, there are only two choices, suspend and do nothing in Power settings for changing the laptop lid close behavior.

If you want to automatic shutdown or hibernate your laptop when lid is closed, here is the step by step how to guide.

1. Open Ubuntu Software, search for and install dconf editor.

install-dconf-editor

For command line, you can run the command below in terminal to install dconf-editor:

sudo apt install dconf-editor

2. Launch dconf Editor and navigate to org -> gnome -> settings daemon -> plugins -> power. Then do:

  • Double click “lid-close-ac-action” line
  • Turn off use default value.
  • Change Custom value to ANYTHING other to the default
  • Do same to “lid-close-battery-action

Although step 2 does not really change the lid close action, it is required before doing following steps in some conditions!

dconf-lid-close-action

3. Open terminal (Ctrl+Alt+T) and run command to open and edit the config file:

sudo apt install gksu && gksudo gedit /etc/systemd/logind.conf

When it opens, find out the line #HandleLidSwitch=suspend, un-comment and change it into:

  • HandleLidSwitch=poweroff to automatic shutdown when lid is closed.
  • HandleLidSwitch=hibernate to automatic hibernate when lid is closed.

You can also change the value to suspend or ignore though they are already available in power settings.

lid-close-action

To apply changes, restart your laptop or run command in terminal to restart the logind service:

systemctl restart systemd-logind.service

About ml

ml is a part time stay-at-home dad who've been using Ubuntu Desktop for a few years. He writes in the free time and wishes to share some useful tips with Ubuntu beginners and lovers.

One comment

  1. I followed these steps and now, somehow, my logind.conf file is gone. Probably my own fault but how do I fix this?