Elogind: Difference between revisions

From Alpine Linux
(configure display manager)
 
(14 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''elogind''' is a login manager and provides support for  
[https://github.com/elogind/elogind '''elogind'''] is a login manager and provides support for  


* setting up necessary permissions for the desktop environment or window manager
* setting up necessary permissions for the desktop environment or window manager
Line 5: Line 5:


== Installation ==
== Installation ==
{{Cmd|# apk add {{Pkg|elogind}}
<nowiki>#</nowiki> rc-update add elogind
<nowiki>#</nowiki> rc-service elogind start}}
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.
{{Cmd|# apk add {{Pkg|polkit-elogind}}
<nowiki>#</nowiki> rc-update add polkit
<nowiki>#</nowiki> rc-service polkit start}}
Set up a [[PAM]] login.
== Hibernating ==
For {{Cmd|# loginctl hibernate}} to work, you must have a swap partition. Check {{Cmd|# lsblk}} for a partition with the mountpoint [SWAP].


<pre>
<pre>
# apk add elogind polkit-elogind
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
# rc-update add elogind
nvme0n1    259:0    0 953.9G  0 disk
# rc-service elogind start
├─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]
</pre>
</pre>
Remember also to add a kernel parameter to resume, ie in {{Path|/etc/default/grub}} :
{{Cat|/etc/default/grub|<nowiki>...
GRUB_CMDLINE_LINUX_DEFAULT="modules=sd-mod,usb-storage,ext4,nvme quiet rootfstype=ext4 resume=/dev/nvme0n1p4"
</nowiki>}}
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 [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 ==
== Configuration ==
Line 16: Line 43:
=== logind.conf ===
=== logind.conf ===


Edit <code>/etc/elogind/logind.conf</code> to configure handling of 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:


<pre>
{{cat|/etc/elogind/logind.conf|...
sed -i 's|#HandlePowerKey=poweroff|HandlePowerKey=suspend|' /etc/elogind/logind.conf
[Login]
</pre>
HandlePowerKey{{=}}suspend
...}}


=== Working with Desktop Environments ===
=== Working with Desktop Environments ===


If using a Window Manager or Desktop Environment, such as [[Sway]], the user must ensure that login session is correctly configured.  When correctly configured, loginctl command should output the following:
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:
 
'''Using [[Sway]] and [[SDDM]]'''
 
<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


<pre>
# using sway and sddm
localhost:~$ loginctl
SESSION  UID USER SEAT  TTY  
SESSION  UID USER SEAT  TTY  
     c1  105 sddm seat0     
     c1  105 sddm seat0     
Line 34: Line 63:


2 sessions listed.
2 sessions listed.
</pre>
</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 ==
 
Doas is used to grant permissions for suspend-to-RAM and brightness control with brightnessctl:
 
apk add doas brightnessctl
# optionally, allow $USER root access with password
adduser $USER wheel
 
In <code>/etc/doas.conf</code>, set
 
permit :wheel
permit nopass $USER as root cmd /bin/loginctl
permit nopass $USER as root cmd /usr/bin/brightnessctl
 
After setting the above, suspend-to-RAM can be triggered by running
 
/bin/loginctl suspend
 
(use full path to executable) and brightness can be adjusted by running
 
/usr/bin/brightnessctl set 100
 
== See also ==
* [https://wiki.gentoo.org/wiki/Elogind elogind - Gentoo Wiki]
* [https://wiki.gentoo.org/wiki/Polkit polkit - Gentoo Wiki]
* [https://wiki.archlinux.org/title/Polkit polkit - ArchWiki]


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 greetd, sddm or lightdm.
[[Category:Desktop]]
[[Category:Seat_manager]]

Latest revision as of 12:22, 23 May 2024

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 # rc-update add elogind # rc-service elogind start

Polkit is used for authentication. Without it some things may not function. You need to install and configure D-Bus to use polkit.

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

Set up a PAM login.

Hibernating

For

# loginctl hibernate

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.

Configuration

logind.conf

Edit /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 ...

Working with Desktop Environments

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 loginctl command should output the following:

Using Sway and SDDM

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

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 such as greetd, SDDM or lightdm.

Doas

Doas is used to grant permissions for suspend-to-RAM and brightness control with brightnessctl:

apk add doas brightnessctl
# optionally, allow $USER root access with password
adduser $USER wheel

In /etc/doas.conf, set

permit :wheel
permit nopass $USER as root cmd /bin/loginctl
permit nopass $USER as root cmd /usr/bin/brightnessctl

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

/bin/loginctl suspend

(use full path to executable) and brightness can be adjusted by running

/usr/bin/brightnessctl set 100

See also