How to disable auto sleep in Ubuntu 18.04 [duplicate]

I recently installed Ubuntu 18.04 in a rather old laptop I have, and am having some major issues with the device going to sleep and then getting stuck in a loop where it goes to sleep every five seconds once woken up. It is a Lenovo G555-0873, and if it works great and fine when coming up after a fresh reboot, but if it ever sleeps, then it gets stuck constantly trying to sleep and is incredibly difficult to troubleshoot because I have to complete every interaction in the ~5 seconds I have before it sleeps again. I've tried disabling it from going to sleep at all by changing the following settings:

In Privacy, I've turned off Screen Lock.

In Power, I've turned off "Dim screen while inactive", set "Blank screen" to never, and turned off "Automatic suspend"

I can't find any other settings that seem like they would effect this sort of thing. Per an old thread on a similar issue, I've also run the following command:

xset -dpms

None of this has seemingly had any effect. The laptop still goes to sleep when left idle, and then proceeds to enter it's strange sleep-loop when brought back up, and loops like that until eventually rebooted. Any assistance or suggestions are appreciated.

Edit: I've determined now that it only happens when the lid of the laptop is shut. If I leave it with the lid open and the laptop idle it never goes to sleep, but it still sleeps instantly once I shut the lid (and then begins the hell of sleep-looping after waking up).


Solution 1:

I finally found a solution looking through some other threads. Here's what I did:

  1. Install gnome-tweak-tool: sudo apt install gnome-tweak-tool

  2. Run gnome-tweaks.

  3. Change the option under "Power" for "Suspend when laptop lid is closed" to "off".

Now the monitor only turns off the screen when the lid is closed, and no longer goes to sleep.

This doesn't really resolve the issue of sleep-looping in case I ever wanted the laptop to actually go to sleep, but it's a good enough solution for me at least.