Find the name of the X window manager

╄→尐↘猪︶ㄣ 提交于 2020-01-21 03:45:58

问题


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?


回答1:


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.




回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/758648/find-the-name-of-the-x-window-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!