Elogind: Difference between revisions

From Alpine Linux
(reworded Installation section and tip to reduce duplicate and clarified the reasoning)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[https://github.com/elogind/elogind '''elogind'''] is a login manager and provides support for  
{{DISPLAYTITLE:elogind}}[https://github.com/elogind/elogind '''elogind'''] is extracted out of "logind" - systemd login manager to be a standalone daemon and provides [[Seat manager]] support by setting up necessary permissions for the desktop environment or window manager and handles poweroff, reboot, suspend and hibernate via '''loginctl''' commands.


* setting up necessary permissions for the desktop environment or window manager
{{Tip|If [[Setup-desktop]] script was used to install your desktop, elogind should [[#Verify working of elogind|already be running]].}}
* handling poweroff, reboot, suspend and hibernate via '''loginctl''' command
 
== Prerequisites ==
 
* [[Polkit#Using polkit with elogind|Polkit must be configured with elogind]] for a feature-rich desktop experience.


== Installation ==
== Installation ==


{{Cmd|# apk add {{Pkg|elogind}}
[[#Verify working of elogind|Verify, if Elogind]] is already installed. If not installed, proceed to install the {{pkg|elogind}} package and add the {{ic|elogind}} service to auto-start using OpenRC:
<nowiki>#</nowiki> rc-update add elogind
 
<nowiki>#</nowiki> rc-service elogind start}}
{{Cmd|<nowiki># apk add elogind
Polkit is used for authentication. Without it some things may not function. You need to install and configure [[D-Bus#Installation|D-Bus]] to use polkit.
# rc-update add elogind
{{Cmd|# apk add {{Pkg|polkit-elogind}}
# rc-service elogind start</nowiki>}}
<nowiki>#</nowiki> rc-update add polkit
<nowiki>#</nowiki> rc-service polkit start}}


Set up a [[PAM]] login.
== Configuration ==


== Hibernating ==
=== Hibernation ===


For {{Cmd|# loginctl hibernate}} to work, you must have a swap partition. Check {{Cmd|# lsblk}} for a partition with the mountpoint [SWAP].
The command to trigger hibernation is: {{Cmd|# loginctl hibernate}}
 
For hibernation to work, you must have a swap partition. Check {{Cmd|# lsblk}} for a partition with the mountpoint [SWAP].


<pre>
<pre>
Line 39: Line 42:
The resume process can be speed up reducing the size of the hibernation images. See the documentation for [https://docs.kernel.org/admin-guide/pm/sleep-states.html?highlight=image_size#basic-sysfs-interfaces-for-system-suspend-and-hibernation image_size] in the kernel docs for the details, but writing 0 to {{Path|/sys/power/image_size}} should make the images as small as possible.
The resume process can be speed up reducing the size of the hibernation images. See the documentation for [https://docs.kernel.org/admin-guide/pm/sleep-states.html?highlight=image_size#basic-sysfs-interfaces-for-system-suspend-and-hibernation image_size] in the kernel docs for the details, but writing 0 to {{Path|/sys/power/image_size}} should make the images as small as possible.


== Configuration ==
=== Power management ===  


=== logind.conf ===
Edit the systemwide config file {{Path|/etc/elogind/logind.conf}} to configure handling of [[Power_management#elogind_and_power_management|power events]], such as suspending the computer when power button is pressed:
 
Edit {{Path|/etc/elogind/logind.conf}} to configure handling of power events, such as suspending the computer when power button is pressed:


{{cat|/etc/elogind/logind.conf|...
{{cat|/etc/elogind/logind.conf|...
Line 50: Line 51:
...}}
...}}


=== Working with Desktop Environments ===
Since <Code>loginctl</Code> requires privilege escalation, allow either the user to be part of wheel group or configure doas to allow running it as an unprivileged user.


If using a Window Manager or Desktop Environment, such as [[Sway]], the user must ensure that login session is correctly configured. When correctly configured, the <code>loginctl</code> command should output the following:
Option1:
# optionally, allow $USER root access with password
  adduser $USER wheel


'''Using [[Sway]] and [[SDDM]]'''
Option2:


<p style="background-color:#f9f9f9; border:1px dashed #2f6fab; line-height:1.1em; padding:1em; font-family:monospace; font-size:10pt; white-space:pre; overflow:auto;"><span style="color:green;">~</span>'''$''' loginctl
[[Setting_up_a_new_user#doas|Doas]] is used to grant permissions for suspend-to-RAM. In the doas config file {{Path|/etc/doas.conf}}, set
permit nopass $USER as root cmd /bin/loginctl


SESSION  UID USER SEAT  TTY
After setting the above, suspend-to-RAM can be triggered by running {{Cmd|$ /bin/loginctl suspend}}
    c1  105 sddm seat0   
    c2 1000 User seat0 tty8


2 sessions listed.
== Troubleshooting ==
</p>


If the output is <code>No session available.</code>, such as in the case of launching Sway from tty, suspend and many other functionality will not work.  The user then must configure a display manager such as {{Pkg|greetd}}, [[SDDM]] or {{Pkg|lightdm|LightDM}}.


== Doas ==
=== Verify working of elogind ===


Doas is used to grant permissions for suspend-to-RAM and brightness control with brightnessctl:
When correctly configured, the <code>loginctl</code> command should not output [[#No session available|'''No session available''']] message. 


apk add doas brightnessctl
When using a Desktop Environment or a Window Manager like [[Sway]] with [[SDDM]], if the elogind login session is correctly configured, the following will appear:
# optionally, allow $USER root access with password
adduser $USER wheel


In <code>/etc/doas.conf</code>, set
<p style="background-color:#f9f9f9; border:1px dashed #2f6fab; line-height:1.1em; padding:1em; font-family:monospace; font-size:10pt; white-space:pre; overflow:auto;"><span style="color:green;">~</span>'''$''' loginctl


  permit :wheel
SESSION UID USER SEAT  TTY
  permit nopass $USER as root cmd /bin/loginctl
    c1 105 sddm seat0   
permit nopass $USER as root cmd /usr/bin/brightnessctl
    c2 1000 User seat0 tty8


After setting the above, suspend-to-RAM can be triggered by running
2 sessions listed.
</p>


/bin/loginctl suspend
=== No session available ===


(use full path to executable) and brightness can be adjusted by running
If the output is <code>No session available</code>, such as in the case of launching Sway from tty, suspend and many other functionality will not work. The user then must configure a [[Display manager|display manager]].


/usr/bin/brightnessctl set 100
It may also be necessary to install <code>util-linux-login</code> to enable the use of the elogind PAM module.


== See also ==
== See also ==
* [https://wiki.gentoo.org/wiki/Elogind elogind - Gentoo Wiki]
* [https://wiki.gentoo.org/wiki/Elogind elogind - Gentoo Wiki]
* [https://wiki.gentoo.org/wiki/Polkit polkit - Gentoo Wiki]
* [https://wiki.gentoo.org/wiki/Polkit polkit - Gentoo Wiki]
* [https://wiki.archlinux.org/title/Polkit polkit - ArchWiki]
* [https://wiki.archlinux.org/title/Polkit polkit - ArchWiki]


[[Category:Desktop]]
[[Category:Seat_manager]]
[[Category:Seat_manager]]

Latest revision as of 16:12, 11 August 2025

elogind is extracted out of "logind" - systemd login manager to be a standalone daemon and provides Seat manager support by setting up necessary permissions for the desktop environment or window manager and handles poweroff, reboot, suspend and hibernate via loginctl commands.

Tip: If Setup-desktop script was used to install your desktop, elogind should already be running.

Prerequisites

Installation

Verify, if Elogind is already installed. If not installed, proceed to install the elogind package and add the elogind service to auto-start using OpenRC:

# apk add elogind # rc-update add elogind # rc-service elogind start

Configuration

Hibernation

The command to trigger hibernation is:

# loginctl hibernate

For hibernation to work, you must have a swap partition. Check

# lsblk

for a partition with the mountpoint [SWAP].

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0 953.9G  0 disk 
├─nvme0n1p1 259:1    0   200M  0 part /boot
├─nvme0n1p2 259:2    0   100G  0 part /
├─nvme0n1p3 259:3    0   805G  0 part /home
└─nvme0n1p4 259:4    0  48.7G  0 part [SWAP]

Remember also to add a kernel parameter to resume, ie in /etc/default/grub :

Contents of /etc/default/grub

... GRUB_CMDLINE_LINUX_DEFAULT="modules=sd-mod,usb-storage,ext4,nvme quiet rootfstype=ext4 resume=/dev/nvme0n1p4"

Note the "resume=" flag with the same partition that was marked as [SWAP].

The resume process can be speed up reducing the size of the hibernation images. See the documentation for image_size in the kernel docs for the details, but writing 0 to /sys/power/image_size should make the images as small as possible.

Power management

Edit the systemwide config file /etc/elogind/logind.conf to configure handling of power events, such as suspending the computer when power button is pressed:

Contents of /etc/elogind/logind.conf

... [Login] HandlePowerKey=suspend ...

Since loginctl requires privilege escalation, allow either the user to be part of wheel group or configure doas to allow running it as an unprivileged user.

Option1:

# optionally, allow $USER root access with password
adduser $USER wheel

Option2:

Doas is used to grant permissions for suspend-to-RAM. In the doas config file /etc/doas.conf, set

permit nopass $USER as root cmd /bin/loginctl

After setting the above, suspend-to-RAM can be triggered by running

$ /bin/loginctl suspend

Troubleshooting

Verify working of elogind

When correctly configured, the loginctl command should not output No session available message.

When using a Desktop Environment or a Window Manager like Sway with SDDM, if the elogind login session is correctly configured, the following will appear:

~$ loginctl SESSION UID USER SEAT TTY c1 105 sddm seat0 c2 1000 User seat0 tty8 2 sessions listed.

No session available

If the output is No session available, such as in the case of launching Sway from tty, suspend and many other functionality will not work. The user then must configure a display manager.

It may also be necessary to install util-linux-login to enable the use of the elogind PAM module.

See also