Make Ubuntu Not Go in Suspend When Laptop Lid is Closed

In a multi-monitor setup, you probably want the laptop lid closed but it should not suspend the system. Here's how to ensure that with Ubuntu.
Warp Terminal

If you use Ubuntu on a laptop, you might have noticed that the system is suspended when you close the lid.

That’s the expected behavior. It saves the battery as well as your work. You lift the lid, the system wakes up, and you can log in and continue your work.

That all sounds good except when you work with a multi-monitor setup. A few people, like me, prefer to have the laptop closed and only use the external monitor(s).

But if closing the laptop lid suspends the system, it creates a problem.

Let me show you how you can change this behavior.

Don’t suspend when laptop lid is closed

Actually, I have noticed that the recent versions of Ubuntu are smarter in this sense. When the laptop is connected to a docking station and you close the lid, it doesn’t go in suspend mode.

That’s the normal expected behavior but it may not work all the time for reasons known to Ubuntu gods.

The good thing is that you can force change this behavior using both GUI and command line.

Let me share both methods.

Method 1: Using GNOME Tweaks

If you are using the default GNOME desktop, you are in luck. Install GNOME Tweaks tool in Ubuntu from the software center or use this command:

sudo apt install gnome-tweaks

Once installed, start the Tweaks application. In the General tab from the sidebar, toggle off the ‘Suspend when laptop lid is closed’ button.

change lid close behavior ubuntu
change lid close behavior ubuntu

That’s it. You should not need a restart for changes to take effect.

Now, let’s talk about the command line method.

Method 2: Change login configuration (for advanced users)

If you look into the content of the file /etc/systemd/logind.conf, you’ll see three different types of default settings for the laptop lid closing.

  • HandleLidSwitch: When the laptop is on battery power
  • HandleLidSwitchExternalPower: When the laptop is plugged into a power outlet
  • HandleLidSwitchDocked: When the laptop is connected to a docking station
laptop lid settings ubuntu
Default laptop lid closing settings

As you can see, the laptop will suspend if the lid is closed irrespective of whether it is connected to power or not. Lid closing is ignored for docking station connections.

If you want, you can change the value of those parameters to one of these as per your preference:

  • lock: lock when lid is closed
  • ignore: do nothing
  • poweroff: shutdown
  • hibernate: hibernate when lid is closed

I would suggest going with ignore if you don’t want your system do anything special when the laptop lid is closed.

You can either edit the /etc/systemd/logind.conf file and uncomment the said settings and change their value, or you create a new file in /etc/systemd/logind.conf.d directory. Create this directory if it doesn’t exist.

I am not going to give you the exact commands. If you are familiar with the command line, you should be able to do it. If you are uncomfortable with the command line, please stick with the earlier GUI method.

I hope this helps you. Let me know if you have any questions.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

It's FOSS

Making You a Better Linux User

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.