ubuntu 服务器的虚拟显示 [英] A virtual display for ubuntu server

查看:30
本文介绍了ubuntu 服务器的虚拟显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:有没有办法将虚拟显示器设置为 Linux 服务器上的默认显示器(这样,如果没有计数器指示,所有启动的 GUI 应用程序都将显示在该显示器上)?

My question is: is there a way to set up a virtual display as default display on a linux server (so that all GUI application launched will be displayed on that display, if no counter indication is made)?

我尝试使用这个:xvfb-run java -jar autoclick.jar,它产生以下输出:

I tried using this: xvfb-run java -jar autoclick.jar, which produces the following output :

searching graphic devices
is Headless:false
screen N°1 width:1600 height:900
just 1 robot click:
Magic button clicked !

这是自动点击代码:

System.out.println("searching graphic devices");
System.out.println("is Headless:"+GraphicsEnvironment.isHeadless());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

int count = 1;
for(GraphicsDevice screen : ge.getScreenDevices())
{
    System.out.println("screen N°"+count+" width:"+screen.getDisplayMode().getWidth()
                                              +" height:"+screen.getDisplayMode().getHeight());
}
{... create a JFrame and add a JButton that closes the application and prints a message to the console when clicked}
System.out.println("just 1 robot click:");
try
{
    robot = new Robot();
    justOneClick(frame.getX()+100, frame.getY()+100);
}
catch(AWTException e)
{
    e.printStackTrace();
}

简而言之,这是我的两个问题:

To make it short, here are my 2 problems:

每次我想在虚拟显示器上启动应用程序时,我仍然必须调用 xvfb-run.这意味着不是我启动的应用程序不会在虚拟显示器上启动.

I still have to call xvfb-run every time i want to launch an application on the virtual display. Which means that applications that are not launched by me are not launched on the virtual display.

我无法在 xvfb-run 创建的显示器上启动另一个应用程序.

I can't launch another application on the display created by xvfb-run.

抱歉我的英语语法不好,感谢您的时间.

Sorry for my bad English syntax, and thank you for your time.

推荐答案

在后台用 Xfvb 设置一个虚拟的 X 服务器,然后相应地设置 DISPLAY 变量:

Set up a virtual X server in the background with Xfvb, then set the DISPLAY variable accordingly:

Xvfb :1 -screen 0 1920x1080x24+32 -fbdir /var/tmp &
export DISPLAY=:1
java -jar autoclick.jar
java -jar autoclick.jar
java -jar autoclick.jar

(一次又一次,一次又一次……)

(and again, and again, and again...)

由于 DISPLAY 变量,在该终端中启动的任何应用程序都将使用您的虚拟 X 服务器.我猜 xvfb-run 所做的是设置一个 Xvfb,运行程序,然后立即再次关闭 Xvfb.

Due to the DISPLAY variable, any application started in that terminal will use your virtual X server. I guess what xvfb-run does is set up a Xvfb, run the program, then immediately shuts down Xvfb again.

这篇关于ubuntu 服务器的虚拟显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆