#1003816 i3 session does not activate systemd graphical-session.target

Package:
i3
Source:
i3-wm
Description:
metapackage (i3 window manager, screen locker, menu, statusbar)
Submitter:
smheidrich
Date:
2022-01-16 06:39:04 UTC
Severity:
wishlist
#1003816#5
Date:
2022-01-16 06:37:55 UTC
From:
To:
systemd defines a special (user) target called graphical-session.target [1]
which should be active when the user is logged into a graphical session.
Currently, when I'm logged into a default i3 session (entered via GDM), this
target is inactive:

  $ systemctl --user status graphical-session.target
  ● graphical-session.target - Current graphical user session
       Loaded: loaded (/usr/lib/systemd/user/graphical-session.target; static)
       Active: inactive (dead)
         Docs: man:systemd.special(7)

If I understood the clarifications in a thread [2] on systemd's mailing list
and the linked slides [3] correctly, this target should be activated by
specifying the session in question as a systemd service with BindsTo=graphical-
session.target and launching this service from the relevant
/usr/share/xsessions/*.desktop instead of launching the session directly.

In i3's case, the /usr/share/xsessions/i3.desktop session definition is
provided by the i3-wm package and just launches i3 directly. This makes perfect
sense, as systemd isn't mandatory on Debian and the aforementioned session-as-
service mechanism wouldn't work at all for people using SysVinit. But perhaps
there could be two session definitions, one with and one without an associated
systemd service?

An objection I expect is that users should just write their own session files
if they need this "feature", but the same would apply to the default
/usr/share/xsessions/i3.desktop file, which is only included for compatibility
with common display/login managers. Ditto for the argument that this is out of
scope for a window manager and gets into desktop environment territory.
Besides, it's not merely a missing feature but a bug (not necessarily in the i3
package but somewhere in the Debian distribution): Promises that are made in
systemd's documentation [1] are not kept when using distribution-provided
graphical session definitions.

Unfortunately, the only precedent for this type of session file in other window
manager or desktop environment packages I could find is in the gnome-session-
common package (apt-file search session.target), so perhaps it would in fact be
better to provide this via a separate package? There are a bunch of packages
for the Openbox window manager that do nothing but provide sessions for running
it along with the non-WM processes of common desktop environments (openbox-
gnome-session, openbox-lxde-session, openbox-kde-session, ...), so a package
providing only a session file for running i3 in a systemd-compatible manner
doesn't sound totally unreasonable to me. This could then be suggested by the
i3 package.

Let me know your thoughts.

Kind regards


[1]:
https://www.freedesktop.org/software/systemd/man/systemd.special.html#graphical-
session.target
[2]: https://systemd-devel.freedesktop.narkive.com/J9pItAjq/graphical-session-
targets-as-standard#post10
[3]: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf