Is it possible to get active window & executable names in X11/Xlib?

房东的猫 提交于 2020-06-24 14:00:26

问题


After looking at RescueTime for windows/mac, it seems that there's a version for linux but doesn't seem up to date. Also, it's the weekends and I want to spend time playing with X11..

I'm thinking of making a simple productivity-polling app, that every short interval polls the active windows, and intercepts (and passes along) mouse and keyboard presses to measure productivity.

Is this possible at all? After checking Xlib I'm at a loss on where to find the binary name of an executable. etc.


回答1:


Finding the PID (and by extension the backing executable) in X isn't necessarily possible (due to the fact that the window might not even be owned by a process on your current box).

See Getting pid and details for topmost window or How to get an X11 Window from a Process ID? for a solution which might work in a limited set of cases (by querying for the _NET_WM_PID property).



来源:https://stackoverflow.com/questions/2391669/is-it-possible-to-get-active-window-executable-names-in-x11-xlib

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