If it uses the wayland, WAYLAND_DISPLAY has a wayland name.
$ echo $WAYLAND_DISPLAY
wayland-0
Otherwise, it will be null.
To turn on the screen, use this command:
xset dpms force on
To turn off the screen, use this command:
xset dpms force off
[note] If you have multiple monitors and want to control monitor by monitor, use xrandr command. See this for more detail: https://adamosk.com/turn-off-monitor-using-command-line/
xset command doesn't work in wayland:
$ xset dpms force off
server does not have extension for dpms option
xset: unknown option force
...
Set WaylandEnable=false in the file of /etc/gdm3/custom.conf.
Then logout and login.