Determine session type (X11, Wayland).
Directly determine session type using $XDG_SESSION_TYPE
environment variable.
$ echo $XDG_SESSION_TYPE
wayland
Determine session type using systemd login manager.
$ loginctl list-sessions
SESSION UID USER SEAT TTY 2 1000 milosz seat0 tty2 1 sessions listed.
$ loginctl show-session 2 --value --property=Type
x11