474

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 login 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?

3
  • 1
    run xprop, this tool will work on xapplications running under emulation but not wayland or gnome-shell on wayland. Commented Aug 10, 2015 at 1:40
  • 9
    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... Commented Mar 22, 2018 at 13:28
  • 4
    Classical SE: An incorrect/incomplete, complicated answer gets 294 upvotes, and the simpler, correct, and complete one gets only 2. Getting the best answer at the top sure is a hard problem to solve.
    – JoL
    Commented Oct 28, 2020 at 19:01

13 Answers 13

576

Obtain the session ID to pass in by issuing:

loginctl

That will show you something like:

SESSION  UID USER          SEAT  TTY
     c2 1000 yourusername  seat0    

1 sessions listed.

In that example, c2 is the session ID.

Then:

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: https://fedoraproject.org/wiki/How_to_debug_Wayland_problems

So, for me it is:

$ loginctl show-session 2 -p Type                                                  
Type=wayland
12
  • 6
    Thanks for the great answer. Please add that OP should run loginctl first to see the sessions.
    – Ho1
    Commented Nov 25, 2016 at 10:33
  • 12
    loginctl show-session `loginctl|grep <YOUR_USER_NAME>|awk '{print $1}'` -p Type
    – solsTiCe
    Commented Dec 7, 2017 at 7:06
  • 11
    According to Fedora 28 docs you can also use echo $WAYLAND_DISPLAY which prints nothing if wayland is not used.
    – robsch
    Commented Jun 25, 2018 at 9:14
  • 11
    @DSJustice your backticks have been markdown'd. One can copy this: loginctl show-session $(loginctl|grep $(whoami) |awk '{print $1}') -p Type
    – Andreas
    Commented Nov 6, 2018 at 7:30
  • 24
    If you don’t use a display manger, this outputs tty no matter whether you use x11 or wayland.
    – Devon
    Commented Mar 12, 2020 at 13:19
455

How to know whether Wayland or X11 is being used?

on X11 systems:

$ echo $XDG_SESSION_TYPE
x11

on some wayland system:

$ echo $XDG_SESSION_TYPE
wayland

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

6
  • 45
    What does it mean if this variable is unset? Commented May 26, 2017 at 6:03
  • 2
    Is there a way to show also the version of the running wayland protocols?
    – sunwarr10r
    Commented Aug 31, 2018 at 8:31
  • 13
    I am a Wayland user without a display manager. This outputs tty.
    – Devon
    Commented Mar 12, 2020 at 13:11
  • 16
    I am an X11 user without a display manager. This outputs tty.
    – JoL
    Commented May 11, 2020 at 19:25
  • 4
    See stackoverflow.com/a/45537237/912144 for the proper way of checking this.
    – Shahbaz
    Commented Aug 23, 2020 at 5:08
105

This works on Fedora and Ubuntu 18.04.5 LTS:

loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type
3
  • 3
    Power of pipes and unix philosophy. Nice. Commented Sep 10, 2018 at 13:07
  • 17
    /me mumbles something about grep ... | awk, but hey, that's fine.
    – rahmu
    Commented Nov 12, 2018 at 14:58
  • 12
    A minor variation: loginctl show-session $(loginctl show-user $(whoami) -p Display --value) -p Type --value I guess this assumes a singe session id per user: I'm not sure whether there can be multiple ids.
    – NickD
    Commented Sep 1, 2020 at 14:50
36

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.

2
  • 4
    For me this failed with an error message: Failed to get session path: Caller does not belong to any known session. Apparently $XDG_SESSION_ID is not set on my wayland session.
    – Calimo
    Commented Aug 29, 2020 at 14:52
  • XDG_SESSION_ID is not set for me, although other XDG_ vars are. (I am running wayland, on Ubuntu gutsy 20.10) Commented Nov 20, 2020 at 15:46
35

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

4
  • 10
    Right, and then if that fails, check DISPLAY to see if X11 is being used.
    – JoL
    Commented May 11, 2020 at 19:28
  • 2
    This works even if you don't use a desktop manager. Other answers produce "tty". This reliable simple answer has a long way to go before it gains its rightful pole position.
    – Paul
    Commented Mar 1, 2023 at 16:33
  • 1
    @JoL A fresh install of Ubuntu 23.10 runs Wayland, but it sets DISPLAY=:0
    – Andrew
    Commented Nov 17, 2023 at 5:28
  • 2
    @Andrew That's probably XWayland, which is why I wrote "then if that fails".
    – JoL
    Commented Nov 17, 2023 at 9:44
12

Tell which session type with POSIX-shell grammar and no sub-shell:

printf 'Session is: %s\n' "${DISPLAY:+X11}${WAYLAND_DISPLAY:+WAYLAND}"

Alternative handling all 4 states:

case $((0${DISPLAY:+1} | 0${WAYLAND_DISPLAY:+2})) in
1) session=X11 ;;
2) session=WAYLAND ;;
3) session='both X11 and WAYLAND' ;;
*) session='neither X11 nor WAYLAND' ;;
esac

printf 'Session is: %s\n' "$session"
11

Give the command

ps aux | grep gnome-shell

It will give the output

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

If Wayland is active.

8
  • 11
    And what if wayland is the default? Commented Sep 21, 2016 at 11:34
  • 4
    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.
    – paulie4
    Commented Nov 5, 2016 at 2:15
  • 2
    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. Commented Nov 23, 2016 at 8:38
  • 4
    gnome-shell only works if you are using gnome as DM.
    – Sebastian
    Commented Mar 27, 2017 at 19:55
  • 1
    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)
    – cbcoutinho
    Commented Mar 11, 2018 at 21:07
10

If you're running Gnome, run the command r in the Alt+F2 menu. It will restart the environment (gnome-shell) in Xorg (without losing windows and processes) but in Wayland it will give the message "Restart is not available in Wayland".

1
  • 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". Commented Feb 3, 2020 at 14:27
7

The simple easy way to find out if you have Wayland or X11 is to open Settings, scroll down to About, and then scroll down to Windowing System, and it will tell you there.

In my own search for the answer to this question, after reading some of these "Answers," and finally finding out which I have through various Terminal commands, I found this much simpler way on my own. I'm brand new to Linux and I've been going through a lot of trouble shooting issues, and this kind of problem often comes up. It is extremely frustrating. Why does everyone offer such convoluted answers instead of the simpler more obvious solution?

3
  • 3
    People sometimes prefer command-line solutions because you can script them. Commented Sep 15, 2022 at 2:06
  • 2
    When you get used to the terminal you will start to appreciate it. Apart from what G-Man wrote, you can also copy paste the commands from a website. You cannot copy paste a sequence of clicks.
    – klutt
    Commented Jan 10, 2023 at 7:04
  • Would have to know what OS/DE you're running for this to be useful. "Settings" for what? There's over a dozen in my gui programs, and the XFCE settings manager only has "about me". There is an "About XFCE" program, but it doesn't mention anything about X11 or wayland.s
    – Xen2050
    Commented Aug 17 at 5:13
5

You could run the xdpyinfo command. It gives information about your current X11 server (and display). It would fail if you don't have one (e.g. in a pure Wayland setting).

2
  • 2
    IMHO, that just means that your wayland session is not pure Wayland. Commented Mar 22, 2018 at 12:06
  • sure but the Q is "how to know whether wayland or xorg is used" for the current session... not how to know if there's a X11 server running Commented Mar 22, 2018 at 12:08
1

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

http://www.fepede.net/blog/2017/04/gnome_shell_extension_xorwayland/

0

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

1
  • 7
    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. Commented May 16, 2015 at 21:30
0

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.

1
  • Cleaner is this to list all programs and their X11 or Wayland dependencies: find . | xargs ldd | grep '^[.]\|x11\|wayland' Commented Feb 3, 2020 at 14:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .