15

I'm running Ubuntu 17.10 on VM.

In the guest I opened GNOME terminal, launched Aptitude with sudo aptitude, then switched to the host machine to do some tasks.
When I returned to the Ubuntu guest it was showing this notification on lock screen:

Power
1 new notification

popup

and after unlocking:

Automatic suspend
Computer will suspend very soon because of inactivity.

popup

Just after unlocking Aptitude says that it can't download packages because the system is offline.

How can I disable this behavior?

Zanna
  • 70,465
N0rbert
  • 99,918

3 Answers3

18

The solution is to disable automatic suspend:

  1. Open GNOME Control Center, go to Power tab (or simply gnome-control-center power)
  2. In Suspend & Power Button set Automatic suspend, to Off when Plugged In.

<code>gnome-control-center power</code>

This will change settings from

$ dconf dump / | grep -i "suspend\|sleep"
sleep-inactive-ac-timeout=900
sleep-inactive-ac-type='suspend' # <
sleep-inactive-battery-timeout=900

$ gsettings list-recursively | grep -i "suspend\|sleep"
org.gnome.desktop.screensaver ubuntu-lock-on-suspend true
org.gnome.settings-daemon.plugins.power button-power 'suspend'
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 900
org.gnome.settings-daemon.plugins.power power-button-action 'suspend'
org.gnome.settings-daemon.plugins.power lid-close-suspend-with-external-monitor false
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend' # <
org.gnome.settings-daemon.plugins.power button-suspend 'suspend'
org.gnome.settings-daemon.plugins.power button-sleep 'hibernate'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 900
org.gnome.settings-daemon.plugins.power lid-close-ac-action 'suspend'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
org.gnome.settings-daemon.plugins.power lid-close-battery-action 'suspend'

to

$ dconf dump / | grep -i "suspend\|sleep"
sleep-inactive-ac-timeout=900
sleep-inactive-ac-type='nothing' # <
sleep-inactive-battery-timeout=900

$ gsettings list-recursively | grep -i "suspend\|sleep"
org.gnome.desktop.screensaver ubuntu-lock-on-suspend true
org.gnome.settings-daemon.plugins.power button-power 'suspend'
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 900
org.gnome.settings-daemon.plugins.power power-button-action 'suspend'
org.gnome.settings-daemon.plugins.power lid-close-suspend-with-external-monitor false
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing' # <
org.gnome.settings-daemon.plugins.power button-suspend 'suspend'
org.gnome.settings-daemon.plugins.power button-sleep 'hibernate'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 900
org.gnome.settings-daemon.plugins.power lid-close-ac-action 'suspend'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
org.gnome.settings-daemon.plugins.power lid-close-battery-action 'suspend'
N0rbert
  • 99,918
  • I don't use a GNONE desktop, so actually had to run env XDG_CURRENT_DESKTOP=GNOME gnome-control-center power but otherwise great suggestion, thanks! – Sam Mason Apr 12 '18 at 09:50
  • 1
    What if this setting is missing from my GNOME, but I still get such notifications? – Suncatcher May 05 '18 at 16:35
  • @Suncatcher Which version do you have? I see this option in 18.04 LTS. – N0rbert May 05 '18 at 16:39
  • I have 18.04 too. My Gnome is 3.28.1 and Power settings look like this. I run Ubuntu on Hyper-V VM, btw. – Suncatcher May 06 '18 at 07:28
  • 1
    I'm running VirtualBox guest. I'm sorry, but I can reproduce this on Hyper-V (I do not have any). You can try to disable it from terminal with gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing' and gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'. – N0rbert May 06 '18 at 09:45
  • Awesome! manual gsettings worked – Suncatcher May 07 '18 at 10:03
  • in 22.04 the panel looks completely different. 3 power options for the laptop. nothing about suspend. – Thomas Covenant Feb 24 '24 at 01:32
7

Summary:

Setting->Power : Suspend: "off"

Or open a terminal, and execute the command:

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'

Detailed:

Use the setting dialog "Power" and set the automatic suspension to "OFF". Sometimes the setting is not available in the setting-dialog; it is simply missing. (e.g. Only the screen-timeout is shown.)

Please use a terminal instead then.

Check the current setting with the command:

gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type

it should reply:

'suspend'

Please check if the key is writable:

gsettings writable org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type

it should reply:

true

Check the range:

gsettings range org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type

it should reply:

enum
'blank'
'suspend'
'shutdown'
'hibernate'
'interactive'
'nothing'
'logout'

And set the value (with single, double or no quote on "nothing") to your choice:

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'

Check afterwards, if the setting has changed:

gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type

it should show your changes:

'nothing'

Hint: Please avoid to use sudo or a root shell, this will prohibit the access to the local settings.

  • The hint to avoid being in a root shell helped a lot! I got a dconf / dbus-launch error otherwise. – John Dec 19 '22 at 13:31
3

Just to add that given the myriad versions of the GUI control centre that appear to be floating around (mine looks nothing like the one upthread) I found the easiest way to make this change was:

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type "nothing"
JLC
  • 31