It looks like the presence of environment $WAYLAND_DISPLAY should work.
You can't rely on $DISPLAY to detect X11 because that exists in both Xorg and Wayland sessions thanks to Xwayland.
It looks like the presence of environment $WAYLAND_DISPLAY should work.
You can't rely on $DISPLAY to detect X11 because that exists in both Xorg and Wayland sessions thanks to Xwayland.