<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 19/09/2021 17:53, Mantas Mikulėnas
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPWNY8XA_TtXBgB=VrdAVLsLV3bwU2O1aO1ytHqCDs4yNBN+Vw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">On Sun, Sep 19, 2021 at 4:05 AM Ed Greshko <<a
href="mailto:ed.greshko@greshko.com" moz-do-not-send="true"
class="moz-txt-link-freetext">ed.greshko@greshko.com</a>>
wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Not a everyday systemd
service writer....<br>
<br>
I've written a user service file to start an app on login.
It works well for Xorg with Environment=DISPLAY=:0.<br>
<br>
But I've found that under Wayland the DISPLAY=:1 after a
logout of Xorg and login to a<br>
Wayland session.<br>
<br>
What would be the proper way to get the DISPLAY environment
varible use it as opposed<br>
to "hard" coding it?<br>
</blockquote>
<div><br>
</div>
<div>The proper way is to have <b>the desktop environment</b>
upload DISPLAY (and whatever else is relevant, such as
XAUTHORITY or WAYLAND_DISPLAY or XDG_SESSION_TYPE) into
systemd --user, so that it would be automatically available
to your service <b>without </b>doing anything special.</div>
<div><br>
</div>
<div>For example, <font face="monospace">gnome-session</font>
does this for GNOME (it calls systemd's
UnsetAndSetEnvironment in gsm-util.c), and <font
face="monospace">/etc/X11/xinit/xinitrc.d/50-systemd-user.sh</font>
handles the bare minimum for other Xorg-based desktops (when
startx is used).</div>
<div><br>
</div>
<div>If KDE integrates with systemd --user in any way (i.e. if
it actually has a "plasma-core.target" that you mention),
I'd really expect it to do the same before it tries to
start its own targets, otherwise they would be kind of
useless.</div>
</div>
<br>
</div>
</blockquote>
<br>
OK......<br>
<br>
I think I see the problem now. I don't need Environment=. But the
issue is that, I assumed, "plasma-core.target" would be<br>
reached only after a user logged in to plasma.<br>
<br>
I was wrong and the user's service is run earlier when the login
screen appears. <br>
<br>
I need to find a way such that the service only runs when a user
logs on to the plasma GUI.<br>
</body>
</html>