8

This is closely related to this question: How can I tell Ubuntu to do nothing when I close my laptop lid?.

I would like to stop Ubuntu from suspending or sleeping when the laptop lid is closed, while still turning the screen off to save power. How can I do that?

This is for a Dell Precision 5550 running Ubuntu 20.04 preinstalled.

Manuel Jordan
  • 1,768
  • 7
  • 30
  • 50
kennyB
  • 153
  • 1
    Which version of Ubuntu are you using, and what brand and model of notebook are you using? Depending on the combination, it might be as simple as a single setting – matigo Nov 25 '21 at 03:46
  • 1
    I think it’s answered here https://askubuntu.com/questions/1358045/how-do-you-disable-the-laptop-lid-switch-in-ubuntu-20-04 - whilst it says it disables the lid switch, it does turn the screen off. – Will Nov 25 '21 at 06:26
  • @Will that solution does not work for me. It successfully stops the computer from sleeping but the screen stays on. – kennyB Nov 25 '21 at 22:05
  • Your question is unclear, It needs more information like your specs, os information and what exactly you want. As it is currently written, It is hard to tell what exactly is the problem – Error404 Dec 11 '21 at 12:52

4 Answers4

4

The answer I think is here: Configure linux laptop to switch off screen but otherwise remain running when lid closed

The steps are

sudo gedit /etc/systemd/logind.conf

change #HandleLidSwitch=suspend to HandleLidSwitch=lock

Then

sudo systemctl restart systemd-logind.service
Manuel Jordan
  • 1,768
  • 7
  • 30
  • 50
2

These settings are not exposed in the Settings dialog, but can be changed with commands or using dconf Editor. Following commands will cause the computer turn off the screen when you close the lid:

gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'blank'
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'blank'

As you see, you can set different actions depending on whether the computer is on AC power (lid-close-ac-action) or on battery power (lid-close-battery-action). Available actions are blank, suspend, shutdown, hibernate, interactive, nothing and logout.

To reset to default, specify reset in the command and leave out the final argument, e.g.

gsettings reset org.gnome.settings-daemon.plugins.power lid-close-ac-action 
vanadium
  • 88,010
1

You already have part of the answer. You do need to edit logind.conf to make sure the laptop doesn't sleep when closing the lid. The second part is you need to set the backlight to turn off after a given amount of time. Edit your /etc/default/grub. Find the line GRUB_CMDLINE_LINUX_DEFAULT= and change it to GRUB_CMDLINE_LINUX_DEFAULT=consoleblank=600 or whatever timeout you like, in seconds. Don't forget to update-grub and reboot.

That's what I have always used, but if you specifically want to turn the screen off when you close the lid, you might also want to look here...https://mensfeld.pl/2018/08/ubuntu-18-04-disable-screen-on-lid-close/

Caleb McKay
  • 704
  • 5
  • 7
0

Simple GUI method

Just need to install GNOME Tweaks and it works well for Ubuntu

Open terminal and install gnome-tweaks and open it.

sudo apt update
sudo apt install gnome-tweaks
gnome-tweaks

After that you can see an option which is Suspend when laptop lid is closed. You just need to disable that option like below image.

gnome-tweaks-menu

Pablo Bianchi
  • 15,657