23

We have a shared office desktop running Ubuntu 18.04 where several jobs (via ssh and screen) often run for weeks on multiple accounts. When logged into an account, sleep/suspend is deactivated through:

  1. Power settings in main System Setting
  2. Using gnome-tweak-tool, setting "Suspend when laptop lid is closed" to off.

This works fine as long as a user with these power settings is always directly logged into the machine (i.e., physically, not via ssh).

The problem is when no user is currently logged in directly i.e., when the machine is at the main login screen (like on boot up). There does not appear to be a way to set sleep/suspend settings when not logged into a specific account. So, if the machine remains on this screen, it eventually sleeps, suspending all the running jobs.

As I mentioned, things work fine as long as some user is logged in. However, this has been viewed as a security risk. So we'd like to find a better system-wide solution.

I should mention that we have another office desktop running Ubuntu 16.04 which does not have this problem.

3
  • maybe something like this? askubuntu.com/a/942987/104223
    – philshem
    Apr 6, 2019 at 9:40
  • 2
    If it's a production machine or something critical, you may want to disable suspend completely. That can be done with what Pasi Suominen showed in his answer ( via /etc/systemd/logind.conf although not via lidswitch setting). If you do insist on tracking a specific remote login, I think it could be done, but not without root-level service running in background. Disabling suspend globally is an easier solution, and is already available, so I'd recommend that. Apr 7, 2019 at 1:57
  • If you want to disable suspend completely, that's doable via policykit. See instructions: sites.google.com/site/easytipsforlinux/… Apr 7, 2019 at 19:12

4 Answers 4

14
+25

When no user is signed on

When no user is signed on the power settings come from psuedo-user ID gdm. The following controls for GDM auto-suspend come from: ArchLinux GDM

GDM auto-suspend (GNOME 3.28)

GDM uses a separate dconf database to control power management. You can make GDM behave the same way as user sessions by copying the user settings to GDM's dconf database.

$ IFS=$'\n'; for x in $(sudo -u username gsettings list-recursively org.gnome.settings-daemon.plugins.power); do eval "sudo -u gdm dbus-launch gsettings set $x"; done; unset IFS

where username is your user's name.

Or to simply disable auto-suspend (also run the command with ac replaced with battery to also disable it while running on battery):

$ sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
4
  • 2
    this gives me a lot of "permission denied" error messages
    – Charon ME
    Aug 21, 2019 at 17:02
  • massive errors here too! Nov 18, 2019 at 8:28
  • for me it's: No such schema “org.gnome.settings-daemon.plugins.power” Feb 4, 2021 at 18:04
  • the trick is to first set a gdm password [sudo passwd gdm], like you had to do for your root user to use su, by default gdm had no password for security reasons I guess. After that the "disable auto-suspend" command works like a charm.
    – Kleajmp
    Jan 28, 2023 at 13:15
7

edit file /etc/systemd/logind.conf

there you can find the line:

#HandleLidSwitch=suspend

change it to:

HandleLidSwitch=ignore

now your login screen ignores your lid switch also.

There is a good ubuntu manual page of logind.conf:

http://manpages.ubuntu.com/manpages/cosmic/man5/logind.conf.5.html

To disable suspend via policykit (systemwide setting) follow instructions on:

https://sites.google.com/site/easytipsforlinux/disable-hibernate-and-suspend

1
  • Isn’t reloading systemd required after this? Or will it be picked up automatically?
    – anon
    May 20, 2023 at 14:10
0

You have to change the settings of the user gdm.

As root execute

sudo -Hu gdm dbus-launch dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout 3600
sudo -Hu gdm dbus-launch dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'"
sudo -Hu gdm dbus-launch dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-timeout 1800
sudo -Hu gdm dbus-launch dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-type "'nothing'"

(Probably you don't need the two lines with the timeout.)

Check the settings with

sudo -u gdm dconf dump /
-3

If you are using UBUNTU 18.04 you can use an indicator named

Caffeine Indicator

you can get it from software store and install it.

Activate it so that it can Manually control the desktop’s idle state

Hope so it will help..

3
  • won't this only run when a user is logged in?
    – philshem
    Apr 12, 2019 at 11:17
  • yes of course you have to log in Apr 12, 2019 at 11:18
  • Caffeine is great for "Auto Suspend" ... Enabled or Disabled, but Ubuntu ... gnome on xorg anyway doesn't pay attention to it! Nov 18, 2019 at 8:41

You must log in to answer this question.

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