5

How do I find the name of the running X window window manager from a program?

If I start another window manager when one is already running, then an error occurs, so there must be a way for the other window manager to detect the first one.

How does it work?

Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
  • 1
    why would you need that information anyway? A X program should not have to care under which window manager it is displayed. – lothar Apr 17 '09 at 01:10

3 Answers3

11

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.

ephemient
  • 198,619
  • 38
  • 280
  • 391
3

The wmctrl command can display information about many EWMH/NetWM-compatible X window managers including their names:

$ wmctrl -m
Name: Compiz
...

Accroding to its Wikipedia page, it works with the following window managers at the present moment (Aug 2012):

  • blackbox >= 0.70
  • icewm
  • kwin (the default WM for KDE)
  • metacity (the default WM for GNOME)
  • openbox >= 3 (the default WM for Lubuntu)
  • sawfish
  • fvwm >= 2.5
  • waimea
  • pekwm
  • enlightenment >= 0.16.6
  • xfce >= 4
  • fluxbox >= 0.9.6
  • matchbox
  • window maker >= 0.91
  • compiz
  • awesome
  • wmfs
dkim
  • 3,930
  • 1
  • 33
  • 37
1

You may find an "atom" that has the information, but I don't think there is a 100% guarantee that all window managers use the same atom. Do an "xlsatoms" to list the atoms on your server, or "xprop" (and click) to see the properties (including atoms and their values) of a particular window.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408