wmctrl -m | grep Name | cut -d: -f2
seems to give the right answer. But it is not necessarily installed.
xlsclients
lists all X clients in the current display (including the window manager) which may be useful, but you'll need to know a list of possible window managers to make a positive identification. e.g
xlsclients | grep -e compiz -e xfwm4