Running Visual Studio Code (VSCode) on Wayland involves a few steps, as Wayland is a newer display server protocol that differs from the traditional X11 system. Here's how you can get VSCode running on Wayland:
User
ELECTRON_..._HINT envvar
Assistant
Visual Studio Code is built on Electron, and Electron provides a set of environment variables that can be used to configure how applications behave on different windowing systems like Wayland and X11. In particular, when you're using Electron-based applications such as VSCode on Wayland, you might encounter or need to set environment variables to modify its behavior.
Step 1: Ensure Wayland is Installed
First, ensure your system is using Wayland. Most modern Linux distributions support Wayland, but it may not be the default. To use Wayland:
On GNOME: Log out of your session and, in the login screen, click the gear icon to select a "GNOME on Wayland" session.
On KDE: Wayland support in KDE Plasma can be selected similarly on the login screen.
Step 2: Install Visual Studio Code
If VSCode is not already installed, you can do so via:
Official Repository: Follow the instructions on the Visual Studio Code website to add their official repository and install it through your package manager.
Snap:sudo snap install --classic code
Flatpak: Using Flathub: flatpak install flathub com.visualstudio.code
Step 3: Run VSCode on Wayland
To run VSCode under Wayland, you need to set an environment variable to force it to use the Wayland backend. You can set this variable in several ways:
To verify that VSCode is running on Wayland, you can use a tool like xeyes. If it opens with xeyes, it's likely running on XWayland. Additionally, checking the application logs or system information within VSCode might help confirm Wayland usage.
This setup should allow you to run Visual Studio Code on systems using the Wayland display server protocol. Keep in mind that support for Wayland is evolving, so some issues may still occur.
ELECTRON_*
Here’s a quick overview of some of these environment variables related to Wayland and their use:
Common Electron Environment Variables for Wayland
ELECTRON_ENABLE_WAYLAND:
This is the primary environment variable to enable the Wayland support in Electron apps.
To use this, set it before running the application:
export ELECTRON_ENABLE_WAYLAND=1
code
ELECTRON_FORCE_HARDWARE_ACCELERATION:
Ensures that hardware acceleration is enabled, which may improve performance on Wayland.
Usage:
export ELECTRON_FORCE_HARDWARE_ACCELERATION=1
ELECTRON_DISABLE_GPU:
Disables GPU hardware acceleration. This might be useful if you encounter rendering issues on Wayland.
Usage:
export ELECTRON_DISABLE_GPU=1
ELECTRON_WAYLAND_WINDOW_HINTS:
This variable can be used to pass specific window manager hints that might improve integration with some Wayland compositors.
Check the Wayland compositor's documentation or Electron's releases/notes for specific hints supported.
ELECTRON_ENABLE_LOGGING:
If you need to troubleshoot issues with running VSCode on Wayland, enable logging to stdout.
Usage:
export ELECTRON_ENABLE_LOGGING=1
Applying Environment Variables
You can set these environment variables directly in your terminal before launching VSCode, or you can configure them in the .desktop entry to apply every time you start VSCode from a menu shortcut:
Modify code.desktop:
Exec=env ELECTRON_ENABLE_WAYLAND=1 code %U
Setting these variables allows you to experiment with different configurations to find the best setup for running Electron applications on your system under Wayland. Note that changes in Electron and VSCode updates may alter how these variables function or if they are necessary, so always check the latest documentation or community forums if issues arise.