#981349 kde/plasma does not start under wayland (solved)

Package:
plasma-workspace-wayland
Source:
plasma-workspace
Description:
Plasma Workspace for KF5 - Wayland integration
Submitter:
Antonio
Date:
2021-08-26 16:12:04 UTC
Severity:
normal
#981349#5
Date:
2021-01-29 17:51:16 UTC
From:
To:
Dear Maintainer,
I recently tried to start a kde/plasma session on wayland server, via
sddm+nouveau, but it return error "kwin_wayland failed backend".
To work I had to modify the file
"/usr/share/wayland-sessions/plasmawayland.desktop" by inserting
additional parameters:

original:
Exec=/usr/lib/x86_64-linux-gnu/libexec/plasma-dbus-run-session-if-needed/usr/bin/startplasma-wayland

modified:
Exec="/usr/lib/x86_64-linux-gnu/libexec/plasma-dbus-run-session-if-needed
/usr/bin/startplasma-wayland --drm --libinput --xwayland plasmashell"

The question is: why are these parameters, necessary for its works, not
already included in plasmawayland.desktop? (or could this be a problem
with my configuration?)
Thank you,
Antonio

#981349#10
Date:
2021-08-26 16:10:06 UTC
From:
To:
This happened to me, too.  I can't tell what the cause in your case
might have been, but in my case it was because I set DISPLAY to ":0"
via ~/.pam_environment which made kwin_wayland believe it is running
within an X server, so it chose the X11 backend without testing if it
could actually connect to the X server first.  Since with SDDM (which
I use, too) the sddm-greeter's X server runs as user sddm, the
logged-in user's .Xauthority file will not match (because it is not
updated when entering a Wayland session) and the connection will fail
with an authentication error.

A remedy would be to actually try to open an X display in
kwin/main_wayland.cpp:automaticBackendSelection() and choose a
different plugin if it fails.  The code could look as simple as this:

#include <X11/Xlib.h>
...
static QString automaticBackendSelection(SpawnMode spawnMode)
{
...
    if (qEnvironmentVariableIsSet("DISPLAY")) {
        if (qEnvironmentVariableIsSet("KWIN_WAYLAND_SKIP_X11CHECK"))
            return s_x11Plugin;

        Display *d = XOpenDisplay(NULL);
        if (d) {
            XCloseDisplay(d);
            return s_x11Plugin;
        }
    }
...
}

Since kwin_wayland already links against libX11.so.6 there would be no
new dependencies.

N.B.: There is another very insidious problem here with how
startplasma-wayland chooses default values.  If startplasma-wayland is
called without arguments it unconditionally runs:

    kwin_wayland --xwayland --exit-with-session=/path/to/startplasma-waylandsession

But if a user modifies the Exec= line in
/usr/share/wayland-sessions/plasmawayland.desktop to e.g.

     /usr/bin/startplasma-wayland --drm

then it runs only this:

    kwin_wayland --drm

The user has no way of knowing (beyond studying the source code) that
he must also specify those other options, too, as otherwise the Plasma
session will not be set up correctly due to a missing X server.  The
lack of a manpage does not help exactly either.

Regards.