[systemd-devel] Xorg or Wayland Environment

Ed Greshko ed.greshko at greshko.com
Sun Sep 19 08:18:06 UTC 2021


On 19/09/2021 14:52, Michael Biebl wrote:
> You don't hard-code it, you just use it?

OK, yes, it is just used.

> In your case, since you have a user service which appears bound to the
> lifetime of a graphical (X/Wayland) session, I guess
> graphical-session.target is what you want.
> See man systemd.special.

I should have specified.  This is actually KDE.  So, I'm using plasma-core.target to ensure that either
window system has started so a widget can be placed in the user's taskbar.

The issue is that the DISPLAY environment variable changes depending on various things.  So, I
can't just use the value in Environment= as it may not match the circumstance.

I could not find when EnvironmentFile= is read.

Would using ExecStartPre= to run a script that creates the EnvironmentFile work?



>
> So far, I think only GNOME implements graphical-session.target though.
>
> Am So., 19. Sept. 2021 um 03:05 Uhr schrieb Ed Greshko<ed.greshko at greshko.com>:
>> 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210919/b9cda344/attachment.htm>


More information about the systemd-devel mailing list