Adding FireFox wayland in the startup script

I want to run FireFox in native Wayland if I log into Wayland, and I also want FireFox to work when I log into X11. Wiki says that I need to add the following script, but it only explains how to do it for Bash. But Manjaro is using Zsh, right?

if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

The wiki was not helpful, so I searched Google and added the code above in ~/.zprofile, but it did not work. Is the syntax different? What should I do?

https://wiki.archlinux.org/title/firefox#Wayland

If you use Manjaro KDE the default shell is still bash. Zsh is only as Konsole profile. So you should follow Bash instructions.

Add a shebang as the first li8ne in the script:

#! /usr/bin/bash
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

For more, see:

No, I am using Gnome.

I did that and log out/in, but it did not work.

I’ve seen you multiple times on here, so I know you’re not new. Please refrain from posting screenshots.

Providing terminal output

When posting terminal output, copy the output and paste it here, wrapped in three (3) backticks, before AND after the pasted text. Like this:

```
pasted text
```

This will just cause it to be rendered like this:

Sed
sollicitudin dolor
eget nisl elit id
condimentum
arcu erat varius
cursus sem quis eros.

Instead of like this:

Sed sollicitudin dolor eget nisl elit id condimentum arcu erat varius cursus sem quis eros.

Alternatively, paste the text you wish to format as terminal output, select all pasted text, and click the </> button on the taskbar. This will indent the whole pasted section with one TAB, causing it to render the same way as described above.

Thereby increasing legibility thus making it easier for those trying to provide assistance.


I do not have a .zprofile file on my computer, so I think that file is wrong.

Rather put the function in ~/.zshrc:

nano ~/.zshrc

Add it to the bottom:

[...]
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

Save, Ctrl+OY, and Exit, Ctrl+XY

then you need to load the file, by sourceing it, so in your terminal, run:

source ~/.zshrc

Or that’s how I’d have done it!

Hope this helps!

Edit:

Else, you can put it in a separate script, and this where I believe the shebang comes in, and source in the .zshrc file.

Classic XY problem.

How are you starting Firefox? If you set the variable in ZSH, you have to start in in ZSH, meaning from the terminal.

Those pictures were in addition to the text version (in the OP, I added that after the text version of the code) and only there to show that I did it, and i thought it could convey some other hints that the text version does not.

The startup script thing was confusing. I had searched the web and pages were saying different things. Some say just “zprofile”, instead of “.zprofile”, and some said “zshrc”, etc. Neither “zprofile” nor “.zprofile” existed on my PC. I first tried “zprofile” and it did not work, and then I saw existing .zshrc, so I added “.”. Wish there were some sort of GUI…

Anyway, I added the lines to the existing .zshrc, but when I ran source ~/.zshrc, it said /home/user/.zshrc:12: = not found. I don’t know what exactly that means but if the 12 is line number, that is where I pasted the code. I tried to search for this error, but I could not find a solution. I thought maybe just logging out/in would load the setting anyway, but that did not work.

# Use powerline
USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
  source /usr/share/zsh/manjaro-zsh-prompt
fi

if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

I am starting it by clicking the icon on the Panel (Dash to Panel). I typed “firefox” in the terminal, but that did not work either. The only way that worked was typing export MOZ_ENABLE_WAYLAND=1 && firefox in one command. But of course, I do not want to start FireFox from terminal. I need a way to make FireFox start in native Wayland mode when I clicked the icon.

Then it should go into ~/.profile

.profile did not exit, so I created one with the following, logged out/in. Did not work.

if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

For wayland, it might be different

~/.config/environment.d/envvars.conf

The right suggestion is to put this code in your ~/.profile

if [ "${XDG_SESSION_TYPE}" == wayland ]; then
  export MOZ_ENABLE_WAYLAND=1
else
  unset MOZ_ENABLE_WAYLAND
fi

Also check that /etc/environment has no string, such as

if [ $XDG_SESSION_TYPE == wayland ]; then
   MOZ_ENABLE_WAYLAND=1
fi

if it has, just remove it

Even this option doesn’t work for me.
I’ve tried .bash_profile, .zshrc, and now .profile, but Firefox executes with XWayland.
Only setting MOZ_ENABLE_WAYLAND=1 in my environment file works…