[HowTo] Check a user session type (Wayland / X11) you are using on Gnome, KDE

Difficulty: ☆☆☆☆☆

There are several ways to find it out.
The article covered:

  • Desktop Environments (DE) of:
    • Gnome;
    • KDE.
  • methods to get info:
    • Graphical UI (GUI);
    • Terminal UI (TUI):
      • for visual reading;
      • for usage in programming (to get a pure string value to use it in your scripts).

Methods using GUI

Gnome
  1. Open the settings application
  2. Select the option about
  3. Look for the Windowing system line where the options are: Wayland or X11

KDE
Info Centre from Start menu
  1. Open Start menu.
  2. Navigate to Info Centre
  3. GUI window will be opened. Check Graphics Platform field.
Info Centre GUI call from terminal emulator
  1. Open a terminal emulator.
  2. Type
kinfocenter about-distro
  1. GUI window will be opened. Check Graphics Platform field.

Methods using TUI

These was tested on Gnome, KDE:

$XDG_SESSION_TYPE environment variable
echo $XDG_SESSION_TYPE

:computer:

Usage in programming
$XDG_SESSION_TYPE

Example:

echo "I use the ${XDG_SESSION_TYPE} user session type.";

Expected output:

I use the x11 user session type.


inxi - command line system information script for console and IRC
inxi -Gy1

And search for the Display field value.


:computer:

Usage in programming
inxi -Gy1 | grep "Display:" | awk '{print $2}'

Example:

session_type=$(inxi -Gy1 | grep "Display:" | awk '{print $2}');

echo "${session_type} is my current session type for now.";

Expected output:

x11 is my current session type for now.


loginctl - systemd login manager

It uses 2 steps to reach the goal, but it provide the way to check a user session type of other users in a system:

loginctl

get Session ID of your user and paste it:

loginctl show-session user_session_id

And search for the Type field value.


:computer:

Usage in programming
session_id=$(loginctl session-status | head -n1 | awk '{print $1}');
session_type=$(loginctl show-session "${session_id}" -p Type --value);

Example:

session_id=$(loginctl session-status | head -n1 | awk '{print $1}');
session_type=$(loginctl show-session "${session_id}" -p Type --value);

echo "My session type is ${session_type}.";

Expected output:

My session type is wayland.
Note for an editor: the test case

Before to submit that section code, please test a possible case of real machine data output (username is m):

$ loginctl
SESSION  UID USER SEAT  TTY 
      2 1000 m    seat0 tty2
      5 1000 m    seat0 

2 sessions listed.
$




Is that information still actual?

We don’t know and try to keep it up to date.
It was verified as worked on the Manjaro Linux OS.

DE edition Verification date Notes
Gnome Mar-2024
KDE Oct-2021

:checkered_flag:


Suggestions for that wiki post editors

They are:
-) please try to improve,
-) in the Is that information still actual section please save any ordering, for example alphabetical by DE;
-) avoid partial verification if you are changing the verification date: if you want to update the Verification date column value, please check that all mentioned methods of the DE you select is still works on that date. So the Verification date value is the date then all the mentioned methods was checked and worked in the selected DE.


Possible keywords and key phrases for indexing engines

How to check a user session type (Wayland / X11) using on KDE GNOME.
Manjaro Linux terminal TUI command line CLI get session type KDE GNOME Wayland X11.

2 Likes

or run wayland-info ? error: we use x11

1 Like

Another option:

pidof Xorg  

# use -q for quiet mode
if pidof -q Xorg; then...  

If you want to see all XDG environment variables and their values:

declare -p ${!XDG@}
1 Like

Propose to expand this to all DE/WM systems when possible:

For Gnome the session can be found using the settings application under the option about Windowing system Where the options are: Wayland or X11

1 Like

The initial post is the wiki post now!
:fireworks:

Dear community member! Please free to improve the wiki post.
Let’s :building_construction: it together!

1 Like

TL3 and above can already see the revisions under the orange pencil icon in the upper right of the post, FYI. :wink: :point_down:

Screenshot from 2021-10-19 17-47-17

1 Like

All the commands listed under TUI have the expected output when using Gnome terminal running the default zsh
(the default manjaro that is shipped in stable)

output
$ echo $XDG_SESSION_TYPE                                                                                
x11

$ loginctl                                                                                           
SESSION  UID USER SEAT  TTY 
      3 1000 h    seat0 tty2

$ loginctl show-session 3 | grep Type                                                
Type=x11

$ inxi -Gazy1 | grep Display                                                                       
  Display: x11

The commands are DE agnostic so far.

1 Like