Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-wayland

sindresorhus0MIT0.1.0TypeScript support: included

Check if the current Linux session is using Wayland

wayland, linux, display, server, x11, xorg, session, desktop, environment, detect, check, is

readme

is-wayland

Check if the current Linux session is using Wayland

Install

npm install is-wayland

Usage

import isWayland from 'is-wayland';

if (isWayland()) {
    console.log('Running in Wayland');
    // Use wl-clipboard tools
} else {
    console.log('Not running in Wayland');
    // Use X11 tools
}

How it works

The package detects Wayland sessions by checking:

  1. WAYLAND_DISPLAY environment variable - The primary indicator set by Wayland compositors
  2. XDG_SESSION_TYPE environment variable - Set by display managers to indicate session type

Returns false on non-Linux platforms.

  • is-docker - Check if the process is running inside a Docker container
  • is-wsl - Check if the process is running inside Windows Subsystem for Linux