Brief: You close the lid of your laptop but it keeps on running instead of going into suspend mode? Here are a few ways how you can make Ubuntu suspend when the lid is closed.
One of the ways to save battery on Ubuntu without losing work is to use the suspend mode. I prefer to link with the lid action of my laptop. If I close the lid of the laptop, it goes to suspend/sleep mode and when I open the lid, it wakes up.
However, there are several users who are facing issues with suspend behavior when the lid of the laptop is closed. Ubuntu simply keeps on running without bothering about going in suspend mode.
There is a confirmed bug on this issue starting Ubuntu 16.04. Unfortunately, this bug has not been fixed even after more than a year.
While I cannot fix the bug, I can surely suggest you a couple of ways so that Ubuntu goes to suspend mode after the lid is closed. Let’s see how to do that.
Fixing Ubuntu won’t suspend when laptop lid is closed
I do hope that these fixes work for everyone but it’s not a guarantee because the bug is hardware dependent and though the workaround works for most laptop models, there are surely a few exceptions.
Let’s start working on it.
Make sure to enable suspend for lid close action
This is a no-brainer. You must make sure that you have the correct settings in place.
Go to System Settings and then click on Power. In the power setting, make sure that option for ‘When the lid is closed’ is set to Suspend.
If you had a different setting here, you should check if you are able to suspend Ubuntu by closing the lid. If not, then follow the workaround in the next section.
Workaround to make Ubuntu suspend when laptop lid is closed
First, ensure that you have pm-utils installed on your system. pm-utils is a collection of scripts that handle suspend and resume. Ubuntu should already have it but no harm in verifying it.
sudo apt install pm-utils
After that, we need to edit the logind.conf file of systemd. This file usually contains the entries that are used by default by systemd. However, all the entries are commented out here. If you change the settings in this file, it will take precedence and over the systemd default settings.
It’s always a good idea to make a backup of configuration files before changing them. Use this command:
sudo cp /etc/systemd/logind.conf /etc/systemd/logind.conf.back
And after that, install gksu so that you can open a graphical application (gedit in this case) from the terminal. You can also use a terminal based text editor like Vim if you are comfortable with that.
sudo apt install gksu && gksudo gedit /etc/systemd/logind.conf
You’ll see lines like these in this file:
#NAutoVTs=6 #ReserveVT=6 #KillUserProcesses=no #KillOnlyUsers= #KillExcludeUsers=root #InhibitDelayMaxSec=5 #HandlePowerKey=poweroff #HandleSuspendKey=suspend #HandleHibernateKey=hibernate #HandleLidSwitch=suspend #HandleLidSwitchDocked=ignore #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no #LidSwitchIgnoreInhibited=yes #HoldoffTimeoutSec=30s #IdleAction=ignore #IdleActionSec=30min #RuntimeDirectorySize=10% #RemoveIPC=yes #UserTasksMax=12288
What you have to do is to remove the # from some of the lines and change it’s value to:
HandleSuspendKey=suspend HandleLidSwitch=suspend HandleLidSwitchDocked=suspend
Save your changes and restart your system. Now check if your system goes to suspend mode when the lid is closed.
If not, you can also try changing the below line (though I am not sure if that makes a difference):
I hope this helps you to fix the annoying issue of Ubuntu not suspending when laptop lid is closed. This should work with Ubuntu 16.04, 17.04 and 17.10. Not sure about Ubuntu 18.04.
Do share your feedback whether it worked for you or not.
Powered by WPeMatico