Seatd: Difference between revisions

From Alpine Linux
(removed the repetetive information for starting sway as the info has already been added to sway)
(added rules with draft tag)
Line 2: Line 2:


When using [[elogind]], seatd is not required and viceversa. Don't add both to auto-start.
When using [[elogind]], seatd is not required and viceversa. Don't add both to auto-start.
{{note|Reading about seatd and elogind, you might get the impression that elogind is required for polkit. But seatd/polkit works fine if you use groups in the polkit rules, only for "subject.active" elogind is required. Which means with seatd you are restricted to YES or NO rules, no AUTH_ADMIN, since agents need POLKIT_IS_SUBJECT.}}


== Installation ==
== Installation ==
Line 18: Line 16:


Ensure that [[XDG_RUNTIME_DIR]] is set before starting your Wayland compositor.
Ensure that [[XDG_RUNTIME_DIR]] is set before starting your Wayland compositor.
== Seatd and polkit ==
{{Draft|The below section needs to be tested further. This notice can be removed, if someone else tests and confirm}}
{{pkg|polkit}} can be used for authentication with seatd if you use groups in the polkit rules. With seatd you are restricted to YES or NO rules.
A sample polkit rule file {{Path|/etc/polkit-1/rules.d/50-my-custom-rules.rules}} which allow members of the "wheel" group to reboot without a password. This rule depends only on group membership which works with seatd can be as follows:{{Cat|/etc/polkit-1/rules.d/50-my-custom-rules.rules|<nowiki>   
    polkit.addRule(function(action, subject) {
        if (action.id == "org.freedesktop.login1.reboot" &&
            subject.isInGroup("wheel")) {
            return polkit.Result.YES;
        }
    });
</nowiki>}}
[[elogind|Elogind]] is required for "subject.active" rules and no AUTH_ADMIN, since polkit agents need POLKIT_IS_SUBJECT. Given below is a sample polkit rule file {{Path|/etc/polkit-1/rules.d/51-require-active-session.rules}} which allow only active local sessions to suspend based on subject.active which requires [[Elogind]] can be as follows:{{Cat|/etc/polkit-1/rules.d/51-require-active-session.rules|<nowiki>
    polkit.addRule(function(action, subject) {
        if (action.id == "org.freedesktop.login1.suspend" &&
            subject.active) {
            return polkit.Result.YES;
        } else if (action.id == "org.freedesktop.login1.suspend") {
            return polkit.Result.NO; // Or polkit.Result.AUTH_ADMIN to prompt for password
        }
    });
</nowiki>}}   


== See Also ==
== See Also ==

Revision as of 07:46, 3 May 2025

Seatd is a seat management daemon, that does everything it needs to do. Nothing more, nothing less. Depends only on libc. Seat management takes care of mediating access to shared devices (graphics, input), without requiring the applications needing access to be root.

When using elogind, seatd is not required and viceversa. Don't add both to auto-start.

Installation

apk add seatd # install seatd rc-update add seatd # configure it to auto-start service seatd start # start it now adduser $USER seat # allow current user to access seatd

If you are already logged in as a $USER, you will need to relogin.

Configuration

Ensure that XDG_RUNTIME_DIR is set before starting your Wayland compositor.

Seatd and polkit

This material is work-in-progress ...

The below section needs to be tested further. This notice can be removed, if someone else tests and confirm
(Last edited by Prabuanand on 3 May 2025.)

polkit can be used for authentication with seatd if you use groups in the polkit rules. With seatd you are restricted to YES or NO rules.

A sample polkit rule file /etc/polkit-1/rules.d/50-my-custom-rules.rules which allow members of the "wheel" group to reboot without a password. This rule depends only on group membership which works with seatd can be as follows:

Contents of /etc/polkit-1/rules.d/50-my-custom-rules.rules

polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.login1.reboot" && subject.isInGroup("wheel")) { return polkit.Result.YES; } });

Elogind is required for "subject.active" rules and no AUTH_ADMIN, since polkit agents need POLKIT_IS_SUBJECT. Given below is a sample polkit rule file /etc/polkit-1/rules.d/51-require-active-session.rules which allow only active local sessions to suspend based on subject.active which requires Elogind can be as follows:

Contents of /etc/polkit-1/rules.d/51-require-active-session.rules

polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.login1.suspend" && subject.active) { return polkit.Result.YES; } else if (action.id == "org.freedesktop.login1.suspend") { return polkit.Result.NO; // Or polkit.Result.AUTH_ADMIN to prompt for password } });


See Also