My laptop has suspend capability:

# cat /sys/power/state
freeze mem

and indeed I can suspend as root:

echo -n mem > /sys/power/state

This works fine. But what would be a minimalist way to enable user (non-root) to suspend ?

I am using Debian Buster, but I don't have systemd installed (I am using old style sysvinit). And I don't have udev daemon running either (I am using the "kernel space" udev).

I would like to achieve user suspend capability with minimal additional packages required.

On earlier Debian version (Wheezy), I could install:

  • pm-utils
  • upower

and then issue a command via dbus. I think it was something like this:

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

this no longer works. Now I have read that upower has changed and the curent verison in Debian 0.99.10 is not supposed to work. but I installed upower from wheezy (0.9.17), just to test it, but that does not work either. The dbus-send command gives me this error:

Error org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 127

But using pm-utils, upower and dbus might not be the simplest setup anyway. What is actually the purpose of pm-utils of upower? Those utilities only work for root. But as root, I already can suspend with echo -n mem > /sys/power/state. What do those utilities bring extra?

I see pm-utils installs lots of various scripts. What else do I need to handle besides issuing echo -n mem > /sys/power/state ?

And how could I achieve all that as user ?

Perhaps writing a simple C program that writes mem to /sys/power/state, and set the s bit same as for instance /usr/bin/passwd has.

Would this be a workable and clean solution? Or would this be considered a "dirty" solution? Are there better solutions?

What else do I need to handle, besides writing mem to /sys/power/state?

Do I need to ifdown and ifup the network ?

  • There are many questions there, I believe it needs to be more focused. I would go for the C program with the s bit, looks totally clean and simple. – Quasímodo Aug 1 '20 at 11:48
  • Do sync (Read man sync). – waltinator Aug 2 '20 at 3:36
  • ifdown and ` ifup` are good things. Post-suspend ifup will reinvigorate your network connection. – waltinator Aug 2 '20 at 3:37

Your Answer

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

Browse other questions tagged or ask your own question.