<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 10/02/2023 12.51, Mantas Mikulėnas
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPWNY8XPUYQ8T4EPKpXa9LfZD=iNjP_Tho+6ygXrtw5XfJj4jQ@mail.gmail.com">
      <div dir="auto">
        <div dir="auto">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <p>The whole graphical session (wayland-wm@${WM}.service
                  or wayland-wm-${WM}.scope depending on uwsm mode of
                  operation) and apps live in the app.slice. Which seems
                  to be in accordance to app.slice description in
                  systemd.special manual. </p>
                <p>But those apps know which session they sort-of belong
                  to because $XDG_SESSION_ID (along with some other
                  vars) is exported by uwsm to systemd activation
                  environment during startup. It seems kinda hacky, but
                  works.</p>
              </div>
            </blockquote>
          </div>
        </div>
        <div dir="auto">They don't really *need* to know it. It rarely
          ever matters, as most things are user-wide now; e.g. polkit
          has long ago been adjusted to consider "any session of this
          user is active" instead of "this specific session is active".</div>
      </div>
    </blockquote>
    <p>Knowing session would be handy for session-aware tools to work on
      current session without specifying it, like for `loginctl
      lock-session`, loginctl terminate-session ''`, or any potential
      generalized "logout" apps.</p>
    <p>Also terminating a session with `systemctl --user start --wait
      wayland-wm@${WM}.service` (or killing the process) does not result
      in stopping of the compositor.</p>
    <p>The compositor, its unit and all the dependencies continue
      running in background, but the tty is now owned by getty and there
      is no way to get back to the graphical session. The only way then
      is to stop the compositor unit manually and start a new one.</p>
    <p>For example I have to modify wlogout logout command to `systemctl
      --user stop  <span class="moz-txt-link-abbreviated"><a class="moz-txt-link-abbreviated" href="mailto:wayland-wm@*.service">wayland-wm@*.service</a></span>`,
      because:<br>
      The default `loginctl terminate-user $USER` would nuke all my
      sessions<br>
      Using arguably the most logical `loginctl terminate-session ''`
      does not work (`Failed to issue method call: Caller does not
      belong to any known session.`).<br>
      Using `loginctl terminate-session $XDG_SESSION_ID` requires this
      var exported to systemd environment.</p>
    <p>And in general `terminate-session` will result in inaccessible
      compositor as described above. A heavier alternative to --wait
      would solve part of those problem, something like --bind that
      would not only make systemctl wait for unit to finish, but stop it
      if systemctl is terminated.<br>
    </p>
  </body>
</html>