power: Disable sleep and hibernate on the system

Closes: #2503

- FreedomBox is a server that is typically always running. If applications such
as GNOME desktop environment are installed, they could, by default, cause system
to sleep or hibernate after a period of idleness (based on peripheral activity).
To ensure that services are always available over the network, prevent all such
applications from sending the system to sleep/hibernate.

- Other types of sleep such as hybrid sleep and suspend and hibernate are also
automatically disabled by systemd if either suspend or hibernate are disabled.

Tests:

- Without the changes, install GNOME. In gdm login screen or in desktop
environment, after 20 minutes (default) the system goes to sleep.

- Create the file in the patch with the appropriate directory in a production
FreedomBox machine. Run 'systemctl daemon-reload'. After this, running
'systemctl suspend' or 'systemctl hibernate' will return an error that the
operation is not supported. In GDM, the suspend button does not appear. In GNOME
desktop environment after login, the suspend button does not appear. Even after
the 15-20 minute period, the system does not go to sleep.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-03-25 22:34:46 -07:00 committed by James Valleroy
parent 73ded6b3ad
commit 7937a7c0d2
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -0,0 +1,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# FreedomBox is a server that is typically always running. If applications such
# as GNOME desktop environment are installed, they could, by default, cause
# system to sleep or hibernate after a period of idleness (based on peripheral
# activity). To ensure that services are always available over the network,
# prevent all such applications from sending the system to sleep/hibernate.
#
# To override the configuration in this file, a system administration can copy
# this file to /etc/systemd/sleep.conf.d/90-my.conf (or /etc/systemd/sleep.conf)
# and set the values to 'yes'.
[Sleep]
AllowSuspend=no
AllowHibernation=no