[systemd-devel] How to properly start user session from DM?
simon.mcvittie at collabora.co.uk
Wed Mar 6 02:39:39 PST 2013
On 06/03/13 10:17, Peter Lemenkov wrote:
> I'm trying to replace "/usr/bin/systemd --user" with something which
> looks more proper - with "/usr/bin/systemctl --user start user@`id -n
> -u`.service" but it logs out almost immediately.
xdm (like other display managers - gdm/kdm/lightdm/etc.) assumes that
the X session is encapsulated by one program - traditionally a window
manager or even an xterm, but these days more often a session-starting
wrapper for a desktop environment, like gnome-session or startkde. When
that program exits, the X session is deemed to have ended, and the
display manager cleans up the login session and goes back to a login prompt.
systemctl does what it's told to do and then exits, which is not
compatible with this model.
To use this model you'd have to either have your "main program"
(gnome-session or openbox or whatever) run as normal, and start a
systemd --user in the background (e.g. via pam_systemd and logind,
<https://bugs.freedesktop.org/show_bug.cgi?id=61129>), or replace your
"main program" with something that signals to systemd --user to start a
target, then waits for something (that target ending? the entire systemd
--user exiting? something else)? that indicates the end of the session.
> * Could someone please explain what's the purpose of this
> /usr/lib/systemd/system/user at .service file and how to use it?
At the moment, it isn't used. The intention appears to be that when
pam_systemd notifies logind that a login1.Session has started, logind
will start user@<uid>.service once per login1.User (union of one or more
overlapping login sessions under the same uid, sharing a XDG_RUNTIME_DIR).
See the thread "RFC: user session lifetimes vs. $DISPLAY" for discussion
of some design issues that need to be resolved before this can work well.
More information about the systemd-devel