KDE Wayland: Startup issues, cant find $DISPLAY variable

Hello! I’m currently using Arch Linux Plasma Wayland package, along with the necessary KDE Connect dependencies. The system runs using SDDM, with automatic login to user akei-ai, with tests also done with non-automatic logins.

My first issue that I have encountered is KDE Connect. Everything works except for URL sharing if KDE connect started at login. I have investigated and it seems that KDE Connect works with URL sharing if I have relaunched it after login, and while Plasma Wayland is running.

After that, I have checked the autostart page in System Settings to create a script, only to realize that some X11 apps, like Discord and Caprine weren’t launching properly.

I have concluded that somehow, Plasma Wayland is not recognizing or creating a $DISPLAY variable at autostart time. I need help in mitigating this issue as I don’t know how would I fix this issue.

LOGS:
Firefox

Jun 18 00:32:36 keideapad systemd[955]: Started Firefox (akei-ai) - Web Browser.
Jun 18 00:32:36 keideapad kdeconnectd[16203]: Error: no DISPLAY environment variable specified

Chromium

Jun 18 00:39:05 keideapad systemd[955]: Started Chromium - Web Browser.
Jun 18 00:39:06 keideapad kdeconnectd[16786]: [16786:16786:0618/003906.071223:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
Jun 18 00:39:06 keideapad kdeconnectd[16786]: [16786:16786:0618/003906.071262:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.

Discord

Jun 18 01:16:43 keideapad discord[11565]: Discord 0.0.27
Jun 18 01:16:43 keideapad systemd[939]: Started Discord.
Jun 18 00:56:31 keideapad systemd-coredump[6172]: [LNK] Process 6012 (Discord) of user 1000 dumped core.

Caprine

Jun 18 01:37:31 keideapad systemd[939]: Starting Caprine...
Jun 18 01:37:31 keideapad systemd[939]: Started Caprine.
Jun 18 01:37:33 keideapad systemd-coredump[16647]: [LNK] Process 16365 (caprine) of user 1000 dumped core.

EDIT: I found that this does not apply to the rebooted state of my laptop. I’m investigating SDDM right now, but I’ll keep out for any suggestions

Looks like 469839 – X11 applications may not autostart properly in a Wayland session due to various important environment variables not being set to me

From the Bug report:

After further investigation I found that autostarted applications don’t have some special environment variables, namely:

  • DISPLAY
  • GTK2_RC_FILES
  • GTK_RC_FILES
  • SESSION_MANAGER
  • WAYLAND_DISPLAY
  • XAUTHORITY

and have these environment variables different from manually started applications: