Score:0

How do I disable screensaver and systemd suspend on Ubuntu 20.04 from command-line or configuration files?

fo flag

I have seen a lot of solutions about gsettigns set and systemctl mask suspend.target ... but none works for me.

My Ubuntu 20.04 has Gnome GUI. And the only thing I want is to completely disable screen to enter sleep, suspend, hibernate, ... states, i.e always active, always bright.

I want it to be done through the config files or command-line utilities (better is to manipulate with config files). What I have done so far and what doesn't work for me:

/etc/systemd/sleep.conf.d/nosuspend.conf

Has the content of (as stated in https://wiki.debian.org/Suspend):

[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

And I also run these two commands in a command-line:

gsettings set org.gnome.desktop.session idle-delay 0
gsettings set org.gnome.settings-daemon.plugins.power idle-dim false

The best result I have achieved is that GUI screen is always bright, however the Automatic suspend warning by the system still appears after some amount of time and then (in a couple of minutes) the screen is sleeping and black.

ojacomarket avatar
fo flag
@Alejandro when Ubuntu is started - the third-party application will occupy the screen completely (foreground running process), so user cannot and should not interact with Ubuntu settings, only application. User insert USB and boots Ubuntu, then application is fired with already configured Ubuntu environment
Score:0
za flag

If you know how to change the settings interactively, you may copy your .config dir temporarly to a second place, then perform the changes interactively, then analyze, which files have changed in the last minutes.

find ~/.config -mmin -5 

Then you filter for the screen saver and make a diff with your copy of these files. You can then copy the changed files to the corresponding file in /etc/skel, to make them default for every new user or create a script to change the few settings with sed/awk/perl/(you name it).

I suspect the right files to look for are

 /etc/skel/.Xdefaults 
 /etc/skel/.xscreensaver 

Changing global settings might be insufficient, since it is common practice, to have system wide settings in the /etc dir, but to override them with the usersettings, but your comment suggests, that the user will not be able to change them.

Note that I'm using X11; for wayland, the details may differ, but the way to find the crucial file(s) might be similar.

ojacomarket avatar
fo flag
thanks for the response! The only file in a `.config` that has been changed is `.config/dconf/user` which is pure binary file
za flag
And are you using wayland? I don't have such a dconf dir (xubuntu-2204).
ojacomarket avatar
fo flag
I use Xorg not wayland. I just have no idea, where this screesaving action comes from (systemd, xorg, gdm?) But none of these solutions have helped.. screen still goes to sleep after amount of time
za flag
Two other places you might look, which are not very lilkely, but I run out of ideas: The bios might have an additional setting and the display (laptop or external?). But if the "automatic suspend" warning is clearly from Ubuntu, these ideas can be ignored.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.