Return name of running WM in bash?

While I am by habit comfortable with bash as a shell, from time to time, I find tiny reasons to believe it's a little dense. One of the things that proves it is: to date, I have not been able to get it to identify what WM it's running inside of or alongside of in an X11 kind of environment (specifically Cygwin/X).

Is there an "echo" variable already set in bash to get it to barf up this information, or would I have to create a function for one? If the latter, could someone give me a nudge, code-wise, in a fair direction?

Thanks.

BZT

Bash cannot know what window manager is running unless there is an environment variable set by the window manager.

In my environment, I see three variables that contain the name of my WM:

$ set | grep -i maker
DESKTOP_SESSION=03WindowMaker
GDMSESSION=03WindowMaker
WMAKER_BIN_NAME=/usr/bin/wmaker

If you have no such variables, you can search the output of ps.