For those using Firefox under GNOME with Wayland I recommend the build from Fedora since it has Wayland activated by default. Certain glitches that do occur under XWayland will be gone. Unfortunately the maintainers of the PKGBUILD didn't update it for a while, so I posted an updated version in the comment section below:
https://aur.archlinux.org/packages/fedora-firefox-wayland-bin (https://aur.archlinux.org/packages/fedora-firefox-wayland-bin)
You've been able to run Firefox with wayland by using MOZ_ENABLE_WAYLAND=1 for about a couple of years now. Maybe even longer. I forgot when that was introduced.
Indeed, but as far as I know, in GNOME with Wayland, there is no convenient way to set environment variables permanently and in addition, the build from Fedora has some other optimizations for GNOME.
Have you tried putting the
export commands in your
~/.profile,
~/.bash_profile or
~/.bashrc?
If I remember right, I tried it and it didn't work in modern versions of GNOME. Some environment variables can be set with systemd, but not all of them:
https://noah.meyerhans.us/2020/07/07/setting-environment-variables-for-gnome-session/ (https://noah.meyerhans.us/2020/07/07/setting-environment-variables-for-gnome-session/)
Not sure how it works with display managers, but I always just log into tty first. That way anything from my bashrc/zshrc whatever gets exported to the shell.
Didn't know that new GNOME bypasses reading the startup files. Well, Wayland and GNOME suck then. Going towards Windowsification along with systemd.
That's why I use DM-less Xorg + dwm + st.
For a (completely cumbersome) workaround, see here (found by web search): https://unix.stackexchange.com/a/326161
Edit: You could also make a copy of Firefox's desktop file which calls a script, and call env MOZ_ENABLE_WAYLAND=1 /usr/bin/firefox inside that script. This wouldn't set that variable system-wide, but only for the started process.
I tried this, but it didn't work well, since the env is injected only when firefox is started through the desktop file. When you cklick onto a link in another application, it does of course not work. Under GNOME it's just not meant to be.
You also have to edit
~/.config/mimeapps.list to redirect all things handled by Firefox's desktop file to the new desktop file calling the script.
For example, I have
text/markdown=mdv.desktop
image/jpg=imv.desktop
text/x-diff=less.desktop
text/plain=less.desktop
text/gemini=lagrange.desktop
text/html=surf.desktop
text/xml=surf.desktop
x-scheme-handler/http=surf.desktop
x-scheme-handler/https=surf.desktop
x-scheme-handler/about=surf.desktop
x-scheme-handler/ftp=surf.desktop
x-scheme-handler/unknown=surf.desktop
x-scheme-handler/gemini=lagrange.desktop
x-scheme-handler/gopher=lagrange.desktop
There is actually a solution that works with GNOME:
Adding MOZ_ENABLE_WAYLAND=1 to /etc/environment.