Xvfb - 启动或连接窗口管理器到Xvfb

3

为了测试目的,我使用Xvfb。 今天,我想用wmctrl命令进行一些测试。我在Python中进行了如下测试:

    display = ":99"
    pXvfb = subprocess.Popen(["Xvfb", display, "-screen", "0", "1024x768x24"])

    # wait that xvfb is up
    time.sleep(1)

    os.environ["DISPLAY"] = display

    p = subprocess.Popen( ["wmctrl", "-l" ] )
    p.wait()


    pXvfb.terminate()

在这个测试中,wmctrl 说:
    Cannot get client list properties. 
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)

我认为这很正常,因为我没有将任何窗口管理器附加到我的Xvfb上。

如何启动一个窗口管理器(对于我的情况,Enlightenment应该是不错的选择),以便仅管理Xvfb?

1个回答

4
几天的工作后,我得出了答案。解决方案尽可能简单:只需设置DISPLAY变量启动窗口管理器即可。因此,在我的Python脚本中,我只需要执行以下操作:
display = ":99"
pXvfb = subprocess.Popen(["Xvfb", display, "-screen", "0", "1024x768x24"])

# wait that xvfb is up
time.sleep(1)

os.environ["DISPLAY"] = display

# start windows manager
pWM = subprocess.Popen( ["/usr/bin/enlightenment_start", ]  )

p = subprocess.Popen( ["wmctrl", "-l" ] )
p.wait()


pXvfb.terminate()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接