13

I'm trying to test a "real" wayland gnome session. I know that not all applications can run on Wayland natively (for this we have XWayland) but at least I would like to have GTK+ applications to do so.

So, I created a ~/.profile file containing

export GDK_BACKEND=wayland
export CLUTTER_BACKEND=wayland

>>> Edit: instead of contents above, you may add this to ~/.profile in order to make it work for both X and Wayland sessions:

WAY=$(ps -aux | head -n -1 | grep "/usr/bin/gnome-shell --wayland")

if [ -z "$WAY" ]; then
    echo X11
else
    export GDK_BACKEND=wayland
    export CLUTTER_BACKEND=wayland
fi

<<<

Then from my GDM login screen (Archlinux) I select gnome on wayland.

Once ready, I start (for example) nautilus (normally from the dash, not from terminal), then I open looking glass, I select "windows" section and I click on nautilus window and I get GType:MetaWindowWayland which tells me that Nautilus is actually running on Wayland instead of XWayland. Super!

GType:MetaWindowWayland

However, if, again from looking glass, I select gnome-sell entry, I get GType:MetaWindowX11 telling me that the shell is running on XWayland.

GType:MetaWindowX11

Mutter seems to be running on Wayland (as for example the clipboard between X and W still does not work), all the GTK+ app that I launch after login are running on Wayland too (GType:MetaWindowWayland) however gnome-shell is still on X11.

My guess is that gnome-shell does not take into consideration ~/.profile while starting the session. Maybe because it is started by the system not by the user? So maybe I have to add

export GDK_BACKEND=wayland
export CLUTTER_BACKEND=wayland

somewhere else?

1
  • 2
    I think that's just the fake X11 root window created by gnome-shell to support XWayland clients. Nov 7, 2015 at 15:15

3 Answers 3

1

I think you have to add that to .bashrc which also works for non-login shells.

0
1

The .bashrc, .bash_profile, .profile and similar files get only sourced if a shell which supports them is started.

In turn only if such a shell is used to launch programs will the the environment variables propagate to the newly launched program.

But there is no reason a program launcher must launch a program through a shell sourcing any of this file.

Especially many modern program launchers launch programs through systemd (user slices), as far as I know this involves Gnome.

There are a bunch or reasons why this makes sense but I won't go into it, as it's off topic.

As far as I know on modern Linux system the only reliable way to set environment variables is through environment.d.

Some places will also recommend PAM env to you, but that this works is more a unintended side effect then a meant feature and should be avoided and might stop working in the future.

For this create a environment.d config file:

.config/environment.d/user-vars.conf

In it, set the environment variables, e.g.:

QT_QPA_PLATFORM=wayland
CLUTTER_BACKEND=wayland
#Makes some games not work, better to run them through XWayland
#SDL_VIDEODRIVER=wayland
ECORE_EVAS_ENGINE=wayland_egl
ELM_ENGINE=wayland_egl

You can use systemctl --user show-environment to see all environment variables a new launched applications will have.

See man environment.d.

The only major drawback is that I have no idea how to "in-session reload" environment.d so that changes get applied to newly started programs. So for changes to take affect you need to restart your session (i.e. fully log out and log in again or login on a new TTY, not just pause your user session).

If I find a way to do so I will post it here.


PS: I have a bit of a funky system where some, but not all programs are launched through systemd. This shouldn't apply to you (as you run Gnome). But if anyone has the same problem I solved it by including export $(systemctl --user show-environment) in my .bash_profile. But you should not need to to it if you don't have a very "hacked together" system.

2
  • You can reload specific variables by using systemctl import-environment. E.g. export FOO=12;, systemctl --user import-environment FOO.
    – Limi
    Apr 30, 2021 at 19:37
  • Also not that on I don't mean that the only reliable way is environment.d because systemd messed things up, but because before environment.d there simple was no reliable way. Even before it, program launchers might not have sourced .profile and similar. And pam_env being usable for it was kinda an accident and even lead to some security problems.
    – Limi
    Apr 30, 2021 at 19:42
1

Too late answer but this is under "unanswered questions", clearing up.

GDK_BACKEND=wayland

is sufficient if you start applications from Terminal inside wayland gnome session.

You can start gnome-shell via tty:

gnome-shell --wayland --display_server

If you already have a running instance you should prefix the command with dbus-run-session:

dbus-run-session gnome-shell --wayland --display_server

All recent versions of Fedora are wayland by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.