Skip to content

Allow compositors to run as systemd user units

Simon Ser requested to merge github/fork/mnussbaum/user-unit-wip into master

Created by: mnussbaum

When a wlroots compositor runs as a systemd user unit there is no session associated with the compositor process. Right now when I try and run sway as a user unit it fails since it can't find a session. Instead we need to attach to an existing user session.

This change first looks for an available session for the process, and if there isn't one falls back to display in the oldest available graphical session via sd_uid_get_display.

This work was modeled after a similar change to mutter - https://gitlab.gnome.org/GNOME/mutter/merge_requests/150.

I've tested that this change allows sway to run as a systemd user unit once I set XDG_SESSION_TYPE=wayland in /etc/environment. The linked mutter change includes a caveat that a single user can't log into a machine multiple times. I believe that since this change first looks for a session associated with the process that we shouldn't be regressing sway in this regard, but I'm not sure how to test and confirm this.

This is also my first attempt at real C code and I am not confident in my memory management, and would appreciate a thorough review there.

Merge request reports