Skip to content

Instantly share code, notes, and snippets.

@qguv
Last active May 21, 2025 16:16
Show Gist options
  • Save qguv/e592dbeaeebc4ee7791d2ae8cfa7ef14 to your computer and use it in GitHub Desktop.
Save qguv/e592dbeaeebc4ee7791d2ae8cfa7ef14 to your computer and use it in GitHub Desktop.
Visual Studio Code: Enable native Wayland support

Native wayland support is now working consistently for me in VSCode, giving much better text rendering. Unfortunately, it's still hidden behind some command-line flags.

By adding some files to /usr/local/*, you can ensure that VSCode always launches with these flags.

Adding launch flags to VSCode

Assuming that the VSCode launcher is /usr/bin/code-oss (as is the case in Arch):

  1. Create /usr/local/bin/code-oss with the following content:
#!/bin/sh
exec /usr/bin/code-oss --enable-features=UseOzonePlatform --ozone-platform=wayland "$@"
  1. chmod a+x /usr/local/bin/code-oss
  2. In /usr/local/share/applications/, create modified versions of any vscode entries in /usr/share/applications/*.desktop, which is where many launchers get their application info. Add the new flags to the Exec= lines, e.g. for Arch:
sudo mkdir -p /usr/local/share/applications/
for f in code-oss code-oss-url-handler; do
    sed -E 's:^(Exec=[^ ]+)(.*)$:\1 --enable-features=UseOzonePlatform --ozone-platform=wayland\2:' < /usr/share/applications/$f.desktop | sudo tee /usr/local/share/applications/$f.desktop
done
  1. If your distro provides simlinks to the "real" vscode launcher, like code to launch code-oss, override those too:
ln -s /usr/local/bin/code-oss /usr/local/bin/code

Troubleshooting

  • restart your application launcher
    • for Gnome: update-desktop-database /usr/local/share/applications
  • ensure that your $PATH includes /usr/local/bin somewhere before /usr/bin
  • check that /usr/local/bin/code-oss is executable
@mushsoooup
Copy link

Great help.

@zDEFz
Copy link

zDEFz commented Sep 26, 2024

Appreciated mate!

@marcorichetta
Copy link

Another way is by setting the ELECTRON_OZONE_PLATFORM_HINT env variable to capture electron apps globally.
You can test it executing ELECTRON_OZONE_PLATFORM_HINT=auto <program>. Then set it permanently.

Ref: https://wiki.archlinux.org/title/Wayland#Electron

@liamor
Copy link

liamor commented Nov 16, 2024

@zDEFz
Copy link

zDEFz commented Nov 16, 2024

@CODE33301
Copy link

Works! Thanks!

@Seneral
Copy link

Seneral commented Jan 9, 2025

For me, while it does switch to wayland (as evident by my wayland-native app launched from within vs code), text rendering actually becomes much worse. With it, small text with fractional scaling gets increasingly blurry, without it, it's always crisp and clear.

@Seneral
Copy link

Seneral commented Jan 9, 2025

Interestingly, this is heavily dependant on fractional scaling.
On my 2560x1600 screen, at 150% fractional scaling (and most fractional scales really), this change absolutely destroys the text clarity.
However, at 145% fractional scaling, it is almost on par with X11 in text clarity, only slightly worse with very small text that I wouldn't use anyway. So I'll be using this fix and 145% scale from now on.
Just a very weird behaviour, especially since X11 is very clear at all scales, and definitely check with your settings carefully if this actually improves anything.

@JonathanJ-L
Copy link

@marcorichetta This worked, thanks.

@2zqa
Copy link

2zqa commented May 21, 2025

If you use Fedora or Ubuntu (or really just GNOME in general), I recommend installing Main Menu on flathub. Navigate to Visual Studio Code (or to your favorite alternative, like VSCodium) and edit the command as such:

/usr/share/code/code --enable-features=UseOzonePlatform --ozone-platform=wayland %F

Apply this to any other entries as well, like the "new window" entry:

/usr/share/code/code --new-window --enable-features=UseOzonePlatform --ozone-platform=wayland %F

And don't forget to press save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment