Kiến Thức Linux

How to Shutdown, Hibernate Ubuntu 17.04 When Lid Closed

power-settings-zesty

power-settings-zesty

This quick tutorial is going to show Ubuntu 17.04 Zesty users how to automatically shutdown (power off) or hibernate Ubuntu laptop when lid is closed.

While the Power settings provides only ‘Suspend’ and ‘Do nothing’ options for your laptop close actions, you can do a little change on Systemd configuration file to do more actions:

1. Open terminal by pressing Ctrl+Alt+T or searching for “Terminal” from start menu. When it opens, run command:

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

Type in your password when prompts and hit Enter. The command installs gksu, which allows graphical tools to ask user password to run program as root, and then open the logind.conf file via Gedit text editor.

edit-lid-close-action

2. When the files opens, uncomment the line #HandleLidSwitch=suspend by removing # at its beginning, and change the value to:

  • HandleLidSwitch=poweroff, shutdown / power off Ubuntu when lid is closed.
  • HandleLidSwitch=hibernate, hibernate Ubuntu when lid is closed.
  • HandleLidSwitch=ignore, do nothing.
  • HandleLidSwitch=suspend, suspend laptop when lid is closed.

auto-hibernate

Save the file and finally restart the Systemd service to apply changes via command:

systemctl restart systemd-logind.service

restart-systemd-service

NOTE:
1. Previous steps do not add shutdown or hibernate options in the Power settings (See top picture), but directly do the function when you close the lid.

2. Power settings lid closed options will not work any more until you re-comment (at # in the beginning) the line the the configuration file.

3. For some laptops, the hibernate function might not work. Run command:

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.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !