Elogind
elogind is a login manager and provides support for
- setting up necessary permissions for the desktop environment or window manager
- handling poweroff, reboot, suspend and hibernate via loginctl command
Installation
# apk add elogind polkit-elogind # rc-update add elogind # rc-service elogind start
Configuration
logind.conf
Edit /etc/elogind/logind.conf
to configure handling of power events, such as suspending the computer when power button is pressed:
sed -i 's|#HandlePowerKey=poweroff|HandlePowerKey=suspend|' /etc/elogind/logind.conf
polkit policies
elogind package does not ship with any polkit policies by default, meaning that no one is allowed to use loginctl command.
We need to add custom polkit rules to allow specific users to execute loginctl.
Example for allowing all users in the user group wheel
to suspend the computer with loginctl suspend:
tee -a /etc/polkit-1/rules.d/88-suspend.rules <<EOF polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.login1.suspend" && subject.isInGroup("wheel")) { return polkit.Result.YES; } }); EOF