10

I'm using Ubuntu Desktop 15.10 on a laptop and it runs an Apache server with SSH as well. When using a GUI, I have the power options set to not sleep at all even when the laptop lid is closed, but recently I stopped the X-System and am now using TTY1 instead to save resources. However, in TTY1, if I close the laptop lid, the computer goes to sleep and prevents the SSH and Apache server from working. Any way to prevent this easily? The realistic answer I bet is to use Ubuntu Server instead (unless I'm mistaken and Ubuntu Server will also sleep on lid close) but I don't exactly want to switch yet unless there's an easy way to switch to it like you can switch from ubuntu-desktop to lubuntu-desktop? Any advice is welcome to prevent the computer from sleeping

3 Answers 3

25

Try to edit the /etc/systemd/logind.conf file and modify the line:

#HandleLidSwitch=suspend

to

HandleLidSwitch=ignore

Then reboot.

1
  • 2
    Nice. At least on 20.04, I can sudo systemctl restart systemd-logind.service, instead of rebooting.
    – xtofl
    Aug 26, 2021 at 13:12
0

You have to do two simple step in your system to prevent lid close effects:

1) Change “When lid is closed”

Go to System Settings >> Power

– change options for “When a lid is closed ” as per given image to

On battery Power: Do Nothing

When Plugged In: Do Nothing

– same way change “show battery status in the menu bar” to Never

2) Now need to change lock system:

Go to

System Settings >> Brightness & Lock

Now turn off the lock as per given below image

source: ubuntu disable suspend on lid close

3
  • 5
    TTY1 usually refers to the command line (no GUI) and he did mention that he stopped the X server. So while your answer isn't bad, it does not apply here.
    – G Trawo
    Aug 1, 2017 at 20:02
  • this is about ubuntu server so no GUI, no system settings. Just command line
    – Tooniis
    Aug 1, 2017 at 20:36
  • Stil I arrived on this question because I wanted to do it from GUI, so upvote from me.
    – Matthieu
    Feb 13, 2022 at 15:15
-1

On more recent linuxmint/xcfe4 distros, the solution involving editing /etc/systemd/logind.conf

HandleLidSwitch=ignore

then

systemctl restart systemd-logind.service

may not work, you probably also will need you to go into the Power Manager app (Menu > Settings > Power Manager) or click on the system tray icon for it, and go to the "Display" tab, and turn off the option "Display power management". Mouse hover over that on/off switch should tell you "Let the power manager handle display power managements (DPMS) not X11." The point is to turn this off, so X11 handles the laptop display. Then your connected LCD monitor can stay on when you close the laptop lid, if that was your issue.

You must log in to answer this question.

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