我试图在我的 X 服务器上找到一个未映射的窗口,以便将它映射回来并向它发送一些EWMH提示。因为窗口未映射,所以我不能使用 EWMH 直接询问窗口管理器。所以我试图通过 Xlib 获得它,但我遇到了它的问题。整个 API 对我来说非常混乱。
我正在使用 Python 的Xlib 包装器。现在让我们看看以下 Python 脚本:
import subprocess
from time import sleep
from ewmh import EWMH
subprocess.Popen(['urxvt']) # Run some program, here it is URXVT terminal.
sleep(1) # Wait until the term is ready, 1 second is really enought time.
ewmh = EWMH() # Python has a lib for EWMH, I use it for simplicity here.
# Get all windows?
windows = ewmh.display.screen().root.query_tree().children
# Print WM_CLASS properties …Run Code Online (Sandbox Code Playgroud)