Proper way to allow non-root to enter s3 sleep state

Recently installed FreeBSD 15 on a Dell Latitude 5490. S3 is supported but it's not an option from KDE Plasma as a power button action. I would assume this is due to permissions. Naturally,
acpiconf -s 3 fails if not root.

I've seen suggestions elsewhere to use sudo, allowing this command to be run without a password. However, is that the best way?
 
KDE (and GNOME, MATE, etc) typically use PolicyKit/ConsoleKit to set permissions on what a user (or group) can and cannot do. You might want to have a look in the /usr/local/etc/polkit-1/ directory.

This file is rather old, and I'm not sure if it'll work for KDE, but you can probably create similar rule files to allow a user to switch the system to standby. I've used the operator group, which is already allowed to shutdown or restart (shutdown(8)) on the command line.

Code:
cat /usr/local/etc/polkit-1/rules.d/60-shutdown.rules
polkit.addRule(function (action, subject) {
  if ((action.id == "org.freedesktop.consolekit.system.restart" ||
      action.id == "org.freedesktop.consolekit.system.stop")
      && subject.isInGroup("operator")) {
    return polkit.Result.YES;
  }
});
 
You can also just simply close the laptop lid to suspend, provided configured accordingly.

Or, re-configure the power button to enter S3 instead of S5 (System shuts down cleanly and powers off). Suspend by power button might be inconvenient, the system needs to be shut down by command (poweroff(8)) or by PolicyKit/ConsoleKit in this case.

It might be possible to use the Fn + Backspace keys to put the machine to sleep (with acpi_ibm(4) loaded). The function is supported by sysctl oid hw.acpi.sleep_button_state: S3 on my machine. devd(8) running in foreground mode does give feedback on "Suspend" "Resume" when the keys are pressed, I have to investigate.

Suspend on lid close:
Rich (BB code):
hw.acpi.lid_switch_state=S3

Suspend on power button (S5 default, see sysctl -a | grep hw.acpi):
Rich (BB code):
hw.acpi.power_button_state=S3
The settings can be permanently saved in /etc/sysctl.conf.

Some models may require a drm-kmod driver for these settings to work. On a ThinkPad E15 AMD without the drm-kmod driver installed, the machine doesn't resume from suspend when the lid was closed (I havent tried power button suspend).
 
Back
Top