Skip to content

Instantly share code, notes, and snippets.

@mujahidk
Last active February 23, 2024 01:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mujahidk/d00f20f25745844255905c43bf6e0d6c to your computer and use it in GitHub Desktop.
Save mujahidk/d00f20f25745844255905c43bf6e0d6c to your computer and use it in GitHub Desktop.
Debian enable/disable sleep

Debian enable/disable sleep

From: https://wiki.debian.org/Suspend

To Disable Sleep

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

To Enable

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
@Jibun-no-Kage
Copy link

Jibun-no-Kage commented Feb 23, 2024

This does not seem to work in Debian 12. System still throws notifications and still goes into sleep mode. Per the Debian wiki, now, you need to create a file at /etc/systemd/sleep.conf.d/disable-suspend-hibernate.conf, although the name of the file is not important, the location of the file is .etc.systemd/sleep.conf.d directory. And set the content to:

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

The above technique works on Debian 10 Buster and newer. See systemd-sleep.conf(5) for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment