$XDG_SESSION_TYPE provide the session X11 or Wayland.
$XDG_SESSION_TYPE
There are also three other way.