我需要检查浏览器的 WM_NAME (比如说 google-chrome)如何实时变化。
我怎样才能做到这一点 ?
答案1
WM_CLASS 永远不会改变。总是一样的。我认为你正试图抓住VISIBLE_NAME
。
这可以通过以下方式完成xprop
:
xprop -spy -id 0x01a00092 _NET_WM_VISIBLE_NAME
_NET_WM_VISIBLE_NAME(UTF8_STRING) = "x11 - How can I monitor in real time the changes to the browsers WM_CLASS - Unix & Linux Stack Exchange ::: http://unix.stackexchange.com/questions/349872/how-can-i-monitor-in-real-time-the-changes-to-the-browsers-wm-class - Pale Moon"
_NET_WM_VISIBLE_NAME(UTF8_STRING) = "Newest Unanswered Questions - Unix & Linux Stack Exchange ::: http://unix.stackexchange.com/unanswered/tagged/?tab=newest - Pale Moon"
_NET_WM_VISIBLE_NAME(UTF8_STRING) = "x11 - How can I monitor in real time the changes to the browsers WM_CLASS - Unix & Linux Stack Exchange ::: http://unix.stackexchange.com/questions/349872/how-can-i-monitor-in-real-time-the-changes-to-the-browsers-wm-class - Pale Moon"
-id xxx
是要监视的目标窗口的窗口 ID。
答案2
您可以用来xtrace
监视窗口属性的变化。在 Debian 中,xtrace
可以使用sudo apt-get install xtrace
.
用法示例:要监视 Chromium Web 浏览器如何更改其WM_NAME
属性,请首先关闭所有 Chromium 窗口,然后运行xtrace -n -- chromium | awk '/ChangeProperty/ && /"WM_NAME"/'
.然后您应该会看到一些与此类似的输出:
001:<:00aa: 32: Request(18): ChangeProperty mode=Replace(0x00) window=0x03200001 property=0x27("WM_NAME") type=0x1f("STRING") data='chromium'
000:<:0101: 24: Request(18): ChangeProperty mode=Replace(0x00) window=0x02400002 property=0x27("WM_NAME") type=0x15d("UTF8_STRING") data=;
000:<:010c: 44: Request(18): ChangeProperty mode=Replace(0x00) window=0x02400002 property=0x27("WM_NAME") type=0x15d("UTF8_STRING") data=0x55,0x6e,0x74,0x69,0x74,0x6c,0x65,0x64,0x20,0x2d,0x20,0x43,0x68,0x72,0x6f,0x6d,0x69,0x75,0x6d;
000:<:0117: 44: Request(18): ChangeProperty mode=Replace(0x00) window=0x02400002 property=0x27("WM_NAME") type=0x15d("UTF8_STRING") data=0x4e,0x65,0x77,0x20,0x54,0x61,0x62,0x20,0x2d,0x20,0x43,0x68,0x72,0x6f,0x6d,0x69,0x75,0x6d;
这意味着该WM_NAME
属性从“chromium”更改为“”,再更改为“Untitled - Chromium”到“New Tab - Chromium”。