53

Subtly broken is worse than frankly broken...

Background:

  1. I already disabled suspend in System Settings -> Power.

  2. The "Suspend" option still appears on the gear menu (not that I expected it to disappear), and the sleep (moon) button on my keyboard still triggers suspend.

  3. The options in #1 are, as others have pointed out, just too easy to hit by mistake once every month or so.

  4. It seems like 1% of platforms get suspend right, because some driver engineer somewhere forgot to check that PCIe or IO space register X gets restored when upon wake. So it's worse than broken: everything usually looks fine after waking up, only it's not. And hopefully none of those corrupted registers affects reliability in a creeping manner, like ECC configuration or storage FIFO depth. But they usually do, in one form or another, which is one reason, for example, why errata against graphics drivers continue infinitely, years after they debut on the market ("graphics chip X hangs an hour after resuming from suspend blah blah blah").

  5. There should be an automated test to see what registers change across a sleep cycle, but few vendors have such a test. The test is complicated somewhat by the fact that some registers are expected to change, such as timers. And worse, sometimes you have to read registers in a certain order or with a particular granularity, or by first writing a read index somewhere else. So this process cannot be centralized at a convenient place in the industry, like Canonical's offices. It's really and truly hopeless unless PCIe is redefined in such a manner that makes comparison easy, which it won't be.

  6. The magical test suite in #5 will never be written because of the chaotic state of driver development. Hence in the absence of that, my question.

  7. I'm so desperate that I don't mind hacking on /etc/whatever_suspend_file, but it would be nice if there were a "polite" way to do this, like that nonexistent checkbox in System Settings -> Power that says "Permanently disable suspend because it was ill-conceived from day one."

  8. NB: I'm not talking about hibernation here, which shouldn't suffer from the problems above because it involves a power cycle. Although in principle, restoring registers from permanent storage could have similar problems.

Veiokej
  • 553
  • 3
    Did you try the answer here: http://askubuntu.com/a/154821/72576? – jobin May 27 '14 at 17:57
  • The crowd-sourced version of #5 can work. It just takes enough people willing to set sleep to 5 minutes or so, and file bug reports. As you note it's hardware specific: but many many machines and people are lucky and sleep is a good thing. – Bryce Aug 29 '18 at 17:51

6 Answers6

54

According to the Debian Wiki, you can also disable it via systemd like so:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

While I have done this on my machine, I can't attest to its effectiveness. Not brave enough to try it out intentionally.

jakar
  • 651
8

On Ubuntu 16.* try this.

Go to:

  • System Settings

Click on:

  • Brightness & Lock

  • Turn screen off when inactive

  • Set it to 'Never'

Hope it helps :)

Hizqeel
  • 1,895
oddCat
  • 89
5

Run the following command to open the file to edit:

sudo -H gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

Scroll to the bottom. Check to see if the following information exists, and if not add them:

[Disable suspend]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no

Doing this makes suspend do nothing when you click it; it will disappear from the menu after you restart your computer.

You can run this command also to prevent computer from sleeping:

gsettings set org.gnome.desktop.session idle-delay 0
Eric Carvalho
  • 54,385
Dusan Milosevic
  • 1,952
  • 6
  • 27
  • 48
  • 1
    That seems like the logical place for this, but I tried it and it doesn't work in my 14.04 environment. But I think you're on the right track, because in this file I can see similar code for disabling hibernation. – Veiokej May 27 '14 at 18:27
  • 6
    This procedur no longer works in 14.04+ releases. See this alternative procedure: http://askubuntu.com/questions/452908/how-to-disable-suspend-in-14-04 – lrosa Dec 19 '15 at 05:52
4

With dconf Editor, navigate to:

org.gnome.settings-daemon.plugins.power

You will find lots of options relating to sleep and suspend.

Anwar
  • 76,649
Jean-Marie
  • 1,958
  • 1
  • 14
  • 11
  • Looks promising, but nothing to modify thus far: dconf read /org/gnome/settings-daemon/plugins/power/lid-close-battery-action
    'nothing'
    dconf read /org/gnome/settings-daemon/plugins/power/lid-close-ac-action
    'nothing'
    dconf read /org/gnome/settings-daemon/plugins/power/idle-dim
    false
    – Veiokej May 29 '14 at 12:57
0

In Ubuntu 20.04 Go to Settings -> Privacy -> Screen Change Blank Screen Delay To "Never"

-1

GUI

Have you looked at:

System -> Preferences -> Power Management

On AC Power Tab, Put computer to sleep when inactive for: "Never"

Terminal

Can you open up "gconf-editor"?

Look in: /apps/gnome-power-manager/timeout

Try setting sleep_computer_ac to 0

I'm not positive if anything else needs to be changed as well.

Get also a look here.

Korkel
  • 1,158
  • 1
  • 10
  • 26
  • No such menu is visible in my 14.04 environment. I don't actually have that file, but I don't think I'd want to mess with the power management timeouts, or at the other extreme, disabling power management wholesale (unless there's actually no way to disable only suspend). – Veiokej May 27 '14 at 18:29
  • It's also not present in 16.04. – MERose Jan 10 '17 at 08:27
  • no /apps/gnome-power-manager/timeout in gconf-editor – markackerman8-gmail.com Nov 14 '19 at 16:49