Configuring Fedora's GDM for screen power saving

In recent Fedora versions (39, 40, 41?) there was a change that made the system go sleep if the login session (GDM) was opened with no activity.

For unattended systems this created a problem as the computer would apparently "freeze". Changing these defaults is not obvious, so I'm documenting it for my future reference.

How does the login screen work

As I currently understand things, the graphical login is managed by the GDM login manager. This manager is launched by the gdm.service SystemD unit, with configuration in /etc/gdm.

While this is good to know, it's not enough to perform the configuration we want to do. In Fedora, GDM is launched under the gdm operating system user, and further configuration of Gnome settings is performed with the gsettings command.

Getting the current Gnome settings for the GDM user

In order to do so, we need to change into the gdm user and make it connect to the right dbus instance:

$ sudo su - gdm -s /bin/bash
$ id
uid=42(gdm) gid=42(gdm) groups=42(gdm)
# This is important:
$ export $(dbus-launch)
$ GSETTINGS_BACKEND=dconf gsettings list-recursively
[... output trimmed ...]

Configuring GDM to never go to sleep or suspend

$ sudo su - gdm -s /bin/bash
$ export $(dbus-launch)
$ GSETTINGS_BACKEND=dconf gsettings get org.gnome.desktop.session idle-delay
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.session idle-delay 0
$ GSETTINGS_BACKEND=dconf gsettings get org.gnome.desktop.session idle-delay
$
$ GSETTINGS_BACKEND=dconf gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
$
$ GSETTINGS_BACKEND=dconf gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
$ GSETTINGS_BACKEND=dconf gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
$
$ GSETTINGS_BACKEND=dconf gsettings list-recursively  | grep -P 'idle-delay|org.gnome.settings-daemon.plugins.power'
org.gnome.desktop.session idle-delay uint32 0
org.gnome.settings-daemon.plugins.power ambient-enabled true
org.gnome.settings-daemon.plugins.power idle-brightness 30
org.gnome.settings-daemon.plugins.power idle-dim true
org.gnome.settings-daemon.plugins.power power-button-action 'suspend'
org.gnome.settings-daemon.plugins.power power-saver-profile-on-low-battery true
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 120
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 900
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'

Configuring GDM to blank the screens after some time

$ sudo su - gdm -s /bin/bash
$ export $(dbus-launch)
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'blank'
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 120

Happy hacking!