Ubuntu 16.04: Shutdown / Hibernate Your Laptop When Lid is Closed

Last updated: May 18, 2016

lid closed activity

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.

power-settings

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”.

dconf-lid-close

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.

handlelidswitch

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.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to remind me outdated tutorial! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

2 responses to Ubuntu 16.04: Shutdown / Hibernate Your Laptop When Lid is Closed

  1. Dear Jim ,
    I have problems to hibernate /resume on 16.04 ,
    I used to hibernate/resume normally in previous versions (ubuntu 14.04,14.10 )
    but after I installed (fresh install,not upgrade) version 16.04 64-bit
    I can’t hibernate/resume , if you could help ,
    or give me some clues
    thanks for your help