Install

Run as root:

apk add seatd
dinitctl enable seatd
dinitctl enable turnstiled
usermod -aG video user
usermod -aG audio user

Run as user:

sway

Run on system startup

I need to trigger PAM to trigger turnstile to create XDGRUNTIMEDIR for me.

I spent 50 minutes to figure this out. Quite a puzzle.

In /home/user/.config/fish/config.fish:

if status is-interactive
    if set -q sway_startup
        sway
        # cound be `dinitctl start sway`
    end
end

In a root shell:

login -f user sway_startup=1

You can probably setup dinit to run sway, but I won’t include it here.

Get Wayland socket

Once you have sway (or any other wayland compositor) running, you can get the wayland socket path in your login sessions (including through SSH).

if status is-login
    # ...

    if set -q XDG_RUNTIME_DIR
        set XAUTHORITY $XDG_RUNTIME_DIR/.mutter-Xwaylandauth.*
        if set -q XAUTHORITY[1]
            set -x DISPLAY :0
            set -x XAUTHORITY
        end
        for socket in $XDG_RUNTIME_DIR/wayland-*
            if test -S $socket
                set -x WAYLAND_DISPLAY $socket
                break
            end
        end
    end
end

Comment on session, seatd

I tried tweaking PAM rules and make doas trigger turnstile. When I did that, turnstiled stopped working.

seatd also stopped working when I stopped the sway process with SIGINT.

Comment on seatd code: The [stackful routine / POSIX thread / POSIX process] concurrency model is not composable. The programmer should not be tasked with ending a process when it is no longer reachable.

What’s composable: [garbage collected graph / handmade DAG] of message queues. Any program that deals with multiple I/O ports should use actor-based concurrency like phony.