答案1
在大多数情况下,打开终端窗口,运行命令
xprop WM_CLASS
..然后单击该窗口将为您提供有关拥有该窗口的进程的足够信息。
如果不,运行命令(假设你已经wmctrl
安装):
wmctrl -lp
根据列表对窗口做出有根据的猜测,复制第三列中的字符串(其 pid)并运行:
ps -p 1337 -o comm=
您刚刚复制的 pid 在哪里1337
。输出将是拥有该窗口的进程。
如果你无法使用终端
..您可以保留一个日志文件,跟踪以下内容:
- 出现新窗口(“NEW”)
- 关闭窗口(“OUT”)
- 新窗口所属的 pid 和应用程序,如输出中所示
ps -e
- 出现/关闭的时间
#!/usr/bin/env python3
import subprocess
import time
#---set the path to the log file below
logfile = "window_log"
#---
# clear the file from previous runs
open(logfile, "wt").write("")
def get_wlist():
try:
return subprocess.check_output(["wmctrl", "-lp"]).decode("utf-8").strip()
except subprocess.CalledProcessError:
pass
def get_wids(currlist):
return [l.split()[0] for l in currlist.splitlines()]
def stamp(s):
t = time.ctime()
return (len(t)*"-")+"\n"+s+" "+t+("\n"+len(t)*"-")
def update_log(data):
with open(logfile, "a+") as log:
for l in data:
log.write(str(l)+"\n")
log.write("\n")
while True:
# wait until the desktop is ready to run wmctrl
wdata1 = get_wlist()
if wdata1:
break
time.sleep(1)
# and then...
wlist1 = get_wids(wdata1)
while True:
time.sleep(1)
wdata2 = get_wlist()
if wdata2:
wlist2 = get_wids(wdata2)
new = [w for w in wlist2 if not w in wlist1]
for item in new:
tstamp = stamp("NEW")
line = wdata2.splitlines()[wlist2.index(item)]
pid = line.split()[2]
match = [p for p in subprocess.check_output(
["ps", "-e"]
).decode("utf-8").splitlines()\
if pid in p][0]
update_log([tstamp, line, match])
out = [w for w in wlist1 if not w in wlist2]
for item in out:
tstamp = stamp("OUT")
line = wdata1.splitlines()[wlist1.index(item)]
pid = line.split()[2]
update_log([tstamp, line])
wlist1 = wlist2; wdata1 = wdata2
确保
wmctrl
已安装sudo apt-get install wmctrl
将脚本复制到一个空文件中,另存为
logwindows.py
- 在脚本头部设置日志文件的路径
通过以下命令运行脚本:
python3 /path/to/logwindows.py
- 如果有必要,如果窗口仅在启动后不久出现,请将其添加到启动应用程序中
该脚本生成如下日志文件:
------------------------
NEW Tue Oct 4 17:14:12 2016
------------------------
0x04400007 0 8427 jacob-System-Product-Name Ubuntu
8427 ? 00:00:01 apport-gtk
------------------------
NEW Tue Oct 4 17:14:28 2016
------------------------
0x04e00084 0 8530 jacob-System-Product-Name Niet-opgeslagen document 1 - gedit
8530 ? 00:00:00 gedit
------------------------
NEW Tue Oct 4 17:14:31 2016
------------------------
0x0108deb3 0 2013 jacob-System-Product-Name Persoonlijke map
2013 ? 00:04:20 nautilus
------------------------
NEW Tue Oct 4 17:14:39 2016
------------------------
0x05200085 0 0 N/A QLE Quicklist Editor
1 ? 00:00:02 systemd
------------------------
OUT Tue Oct 4 17:14:55 2016
------------------------
0x05200085 0 0 N/A QLE Quicklist Editor
由于您无法控制窗口出现的时间,但您能控制关闭时间,这应该在任何情况下都为您提供有关窗口的足够信息。
答案2
回答问题的前半部分How can I identify what produces this empty window
,打开窗口,打开终端并输入xlsclients
:
dell bamfdaemon
dell ibus-ui-gtk3
dell ibus-x11
dell unity-settings-daemon
dell unity-panel-service
dell indicator-printers-service
dell indicator-keyboard-service
dell unity-fallback-mount-helper
dell polkit-gnome-authentication-agent-1
dell nm-applet
dell gnome-software
dell nautilus
dell compiz
dell telepathy-indicator
dell gnome-terminal-server
dell update-notifier
dell notify-osd
dell hud-service
dell google-chrome-stable
dell conky
然后关闭窗口并xlsclients
再次运行。运行窗口的进程将是第一个列表中的进程,但不是在第二个列表中的进程。
找到进程名称是停止它的第一步。
嗨嗨。