[systemd-devel] Xorg or Wayland Environment

Ed Greshko ed.greshko at greshko.com
Sun Sep 19 11:11:24 UTC 2021


On 19/09/2021 17:53, Mantas Mikulėnas wrote:
> On Sun, Sep 19, 2021 at 4:05 AM Ed Greshko <ed.greshko at greshko.com> wrote:
>
>     Not a everyday systemd service writer....
>
>     I've written a user service file to start an app on login. It works well for Xorg with Environment=DISPLAY=:0.
>
>     But I've found that under Wayland the DISPLAY=:1 after a logout of Xorg and login to a
>     Wayland session.
>
>     What would be the proper way to get the DISPLAY environment varible use it as opposed
>     to "hard" coding it?
>
>
> The proper way is to have *the desktop environment* 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 *without *doing anything special.
>
> For example, gnome-session does this for GNOME (it calls systemd's UnsetAndSetEnvironment in gsm-util.c), and /etc/X11/xinit/xinitrc.d/50-systemd-user.sh handles the bare minimum for other Xorg-based desktops (when startx is used).
>
> 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.
>

OK......

I think I see the problem now.  I don't need Environment=.  But the issue is that, I assumed, "plasma-core.target" would be
reached only after a user logged in to plasma.

I was wrong and the user's service is run earlier when the login screen appears.

I need to find a way such that the service only runs when a user logs on to the plasma GUI.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210919/cee4155e/attachment-0001.htm>


More information about the systemd-devel mailing list