systemd-suspend.service man page:

Note that scripts or binaries dropped in /lib/systemd/system-sleep/ are intended for local use only and should be considered hacks. If applications want to be notified of system suspend/hibernation and resume, there are much nicer interfaces available.

So what are some of these "nicer interfaces" that I can use to get notified before suspension? (would be nice if it is before n sec/min)


"Nicer interfaces" is probably referring to the Inhibitor Locks implemented in systemd-logind.service, which includes a logic to inhibit system shutdowns and sleep states.

From man systemd-logind.service:


systemd-logind is a system service that manages user logins. It is responsible for:

  • ...
  • Implementing a shutdown/sleep inhibition logic for applications


For more information on the inhibition logic see the Inhibitor Lock Developer Documentation.

Another solution that I can think of is to write a systemd service, see https://www.freedesktop.org/software/systemd/man/systemd.unit.html and this related question for example.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.