By the EWMH spec, a compliant window manager will set the _NET_SUPPORTING_WM_CHECK
property on the root window to a window ID.
If the _NET_SUPPORTING_WM_CHECK
property exists and contains the ID of an existing window, then a ICCCM2.0-compliant window manager is running. If the property exists but does not contain the ID of an existing window, then a ICCCM2.0-compliant window manager exited without proper cleanup. If the property does not exist, then no ICCCM2.0-compliant window manager is running.
That window (not the root window, but the one described by a property on the root window) should have a _NET_WM_NAME
property on it, which is what you are looking for.