How to detect whether a window manager is running using a login script?

I would like to put a condition around a login script: Auto-run certain tools when no window manager is active, such as screen or mc.

What’s the simplest test to do that?