How can I tell Ubuntu to only turn the screen off when I close my laptop lid?

This is closely related to this question.

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.


Solution 1:

The answer I think is here.

The steps are

sudo gedit /etc/systemd/logind.conf

change #HandleLidSwitch=suspend to HandleLidSwitch=lock

Then

sudo systemctl restart systemd-logind.service

Solution 2:

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/