How to know whether Wayland or X11 is being used

  • So I just installed the latest Kali Linux on my laptop which was based on Debian 7 (oldstable). I then dist-upgrad-ed the whole thing to Debian 8.

    I've always wanted Wayland instead of X11, so I installed the necessary packages. Then created a minimal ~./config/weston.ini configuration. Now, from the Gnome log-in screen: Login Screen

    I can boot to Gnome on Wayland or LXDE (among others). The previous with very limited success and the latter (LXDE) almost perfectly, though the panel needs setting up (I have to look up freedesktop).

    Anyways, in LXDE, the GUI is more responsive than it was on the oldstable and possibly as fast when it was running windows 7. I was pleased.

    But I want to know if this is because of all the library/module upgrades from Debian 7 to 8 or from using Wayland (if I really am using Wayland at all). I skimmed through htop and found a /usr/bin/Xorg running and no process named "wayland". So which one am I currently running?

    run xprop, this tool will work on xapplications running under emulation but not wayland or gnome-shell on wayland.

    I guess I'm the only one to notice that while the OP said he was operating on debian, the screenshot he presented is clearly fedora...

  • Obtain the session ID to pass in by issuing:



    loginctl show-session <SESSION_ID> -p Type

    If you want all this on a single command:

    loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}'

    Use the one corresponding to your user name.

    Refer to:

    So, for me it is:

    $ loginctl show-session 2 -p Type                                                  

    Thanks for the great answer. Please add that OP should run `loginctl` first to see the sessions.

    ``loginctl show-session `loginctl|grep |awk '{print $1}'` -p Type``

    confirmed working on ubuntu 17.10 with gnome-session... surprisingly I'm getting x11

    I think this detects whether the session you've logged into is wayland but it doesn't tell a script that's running in an x11 terminal that it's not in wayland.

    According to Fedora 28 docs you can also use `echo $WAYLAND_DISPLAY` which prints nothing if wayland is not used.

    The best answer ! you are a tank. +10 :D

    @DSJustice your backticks have been markdown'd. One can copy this: `loginctl show-session $(loginctl|grep $(whoami) |awk '{print $1}') -p Type`

    If one prefers verbose commands, the relevant command is `loginctl show-session 2 --property=Type`. Also worth taking a look at the Fedora 29 documentation (that @robsch mentioned) which introduces the `xlsclients` (X11 Legacy Server Clients) command.

    If you don’t use a display manger, this outputs `tty` no matter whether you use x11 or wayland.

  • How to know whether Wayland or X11 is being used?

    on X11 systems:

    $ echo $XDG_SESSION_TYPE

    on some wayland system:

    $ echo $XDG_SESSION_TYPE

    edit: This doesn't seem to work in some cases. See comments & use antismap's answer instead

    What does it mean if this variable is unset?

    Is there a way to show also the version of the running wayland protocols?

    I am a Wayland user without a display manager. This outputs `tty`.

    I am an X11 user without a display manager. This outputs `tty`.

  • This works on fedora

    loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type

    Power of pipes and unix philosophy. Nice.

    /me mumbles something about `grep ... | awk`, but hey, that's fine.

    It also works on Kubuntu 19.10.

  • I like Ayush's answer the best, but thought I'd say that Andreas's answer can be done in one line:

    loginctl show-session "$XDG_SESSION_ID" -p Type

    You can additionally pass --value to drop the Type= prefix.

  • Give the command

    ps aux | grep gnome-shell

    It will give the output

    /usr/bin/gnome-shell --wayland --display-server

    If Wayland is active.

    And what if `wayland` is the default?

    My "gnome-shell" process was not running with the --wayland option, but when I ran `ps aux | grep wayland`, I found that /usr/bin/Xwayland was running.

    Often you have two `gnome-shell` processes: one used for gdm, and one used for the user session. Often gdm's gnome-shell uses wayland but the user session's gnome-shell uses X11.

    Xwayland is a process that bridges between X11 applications and the Wayland display server. Its presence implies that you are running Wayland already -- but check the above caveat, it's possible Wayland is only used for the login screen.

    `gnome-shell` only works if you are using gnome as DM.

    A suggestion - I needed to run `ps aux` with the 'wide' option (`w`), otherwise output got cutoff and grep didn't read anything (`ps aux w | grep gnome-shell`)

    Incorrect. Just depends on the gnome-shell defaults.

  • (try to) Run the command 'r' in the Alt+F2 menu. It will restart the environment in Xorg (without losing windows and processes) but in wayland it will give the message "Restart is not available in Wayland".

    Via Alt+F2 my Kubuntu 19.10 starts Robo3t, and via terminal i get "Command 'r' not found, but can be installed with: sudo apt install r-cran-littler".

  • The simplest thing to do is to check whether WAYLAND_DISPLAY variable is set or not.

    Right, and then if that fails, check `DISPLAY` to see if X11 is being used.

  • No, I've noticed a pid called Wayland in htop, when I've switched to Wayland for giggles. Unless it's changed that's what one should see. Update: Here is a screengrab showing Wayland process.

    enter image description here

    I don't see a `wayland` process in your screengrab; the line you've highlighted is a `dbus-launch` process, starting a session called `gnome-wayland`.

  • if you want a visual hint, I wrote a simple GNOME Shell extension that shows an icon that tells you whether you are running Wayland or Xorg

  • Well you could also just check if applications are running in their wayland native form:

    cd /usr/bin
    ldd $application_name | grep wayland

    Furthermore, to check which binaries have wayland support you could try:

    cd /usr/bin
    find . | xargs ldd | grep wayland -B 55

    The above is not really very clean but it works. You can further pipe it to a file and then use vim to navigate.

    cd /usr/bin
    find . | xargs ldd | grep wayland -B 55 >> candidates
    vim candidates
    # Use vi movement

    The -B flag stands for before and helps to print the binary name.

    You could check this for more details. This answer adapted from this question.

    Cleaner is this to list all programs and their X11 or Wayland dependencies: `find . | xargs ldd | grep '^[.]\|x11\|wayland'`

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM