I have a dell laptop that i just installed Ubuntu server 18.04 LTS on, and that i'm using as a Plex / TVHeadend server. I'd like to stop the laptop from going to sleep when the lid/laptop screen is closed, but still allow the screen to shut off.

Currently I modified /etc/systemd/login.conf and set


The only problem is that now the screen never shuts off when the lid is closed. Since this will be left running 24/7, i'd like the screen to shut off so as not to generate extra heat and save on power

Any suggestions?


4 Answers 4


"Uncomment" the following keys and change it's values to ignore :


Worked for me even when it's on battery.

  • Very helpful answer. Solved my problem, although one had to edit loginD.conf. Without d no file is found. I guess that this was a typo?
    – Jeremy
    Jan 19, 2020 at 20:35
  • It seems only HandleLidSwitch=ignore is enough for my Asus laptop.
    – Dino Tw
    Mar 5, 2022 at 0:20

How about installing gnome-tweaks and doing this with a GUI?

Run apt-get install gnome-tweaks in a terminal, launch Gnome tweaks, and go to the power section in the GUI and disabling suspend when laptop lid is closed

  • 1
    That might work, but for my scenario i wanted to run the server without the GUI and extra overhead or security patches related to running it that way, so for me it wasn't an option. It might be for others though. May 9, 2019 at 15:38

After all this time I finally figured it out

Since Ubuntu 18.04 doesn't have a /etc/rc.local file by default we need to create one.

sudo vi /etc/rc.local

press i to enter insert mode

Type the following 3 lines

setterm --blank 1
exit 0

Next press escape, then type :wq to save and quit vi

Now change the permissions so the file can execute

sudo chown root /etc/rc.local
sudo chmod 755 /etc/rc.local

now restart the rc-local service. Type the following

systemctl restart rc-local
  • I forgot to mention setterm --blank 1 makes the screen blank after 1 minute of inactivity. The number can be between 0 and 60 I believe. Since i'm using the laptop as a server and using SSH to connect to it, I want the screen to go to sleep quickly Apr 1, 2019 at 3:16

I have had the same issue and no luck trying to search online. Past Ubuntu versions had this option available iirc, but it seems 18.04 does not...

Currently, my workaround is to set blank screen to some time interval, and then just shut my computer lid (with the same HandLidSwitch=ignore setting), then let time pass until it auto-blanks the screen by itself. However this isn't exactly convenient and prevents you from having your own settings for how long screen blanking takes (for example, I prefer that my screen never blanks during idle usage - not compatible with this workaround).

Overall, Ubuntu 18.04's settings for sleeping your computer / blanking the screen seem very cumbersome... there doesn't seem to me to be a way to manually suspend / sleep my computer if I've changed the lid-close functionality, for example.

  • Just wondering how you set the screen to blank? I tried googling it, but only found references to doing this via the UI and not by command line Nov 12, 2018 at 23:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .