简体   繁体   English

如何在Linux下用C制作图形终端?

[英]How to make a graphical terminal in C under linux?

I'm using /bin/sh to execute some commands, but some of those commands require me to have a "graphical terminal" which I don't really know what that means, those commands give wrong output on my software, but correct output on the normal Gnome/KDE Terminal. 我正在使用/bin/sh来执行一些命令,但是其中一些命令要求我有一个“图形终端”我不知道这意味着什么,这些命令在我的软件上输出错误,但输出正确在正常的Gnome/KDE终端上。

I was wondering if there is away to tell the underlying X Window Session that my software is a "graphical terminal"? 我想知道是否有机会告诉底层的X Window Session我的软件是一个“图形终端”?

As @ugoren said, the DISPLAY variable is what is used to find the X Window System from applications. 正如@ugoren所说, DISPLAY变量用于从应用程序中查找X Window系统。 If X is not running in the background, the variable will be unset. 如果X未在后台运行,则将取消设置该变量。

You can start a new X server using xinit from your script if you cannot talk to the old one; 如果您无法与旧脚本通信,可以使用脚本中的xinit启动新的X服务器; ideally, this would be something like Xvnc (which does not need hardware access). 理想情况下,这将类似于Xvnc(不需要硬件访问)。

If I understand correctly you are trying to run application on a remote machine or at least one that doesn't run any X Server . 如果我理解正确,您尝试在远程计算机上运行应用程序,或者至少在不运行任何X服务器的计算机上运行应用程序。 If that is the case you might try to use Xvfb which creates a virtual server which allows applications to connect to it and "draw" windows. 如果是这种情况,您可能会尝试使用Xvfb创建一个虚拟服务器,允许应用程序连接到它并“绘制”窗口。

Normally, software that uses X windows relies on the DISPLAY environment variable. 通常,使用X窗口的软件依赖于DISPLAY环境变量。
It's value should be something like 10.0.0.1:0.0 , where 10.0.0.1 is your IP address (I'm not sure what 0.0 is, but 0.0 normally works). 它的值应该是类似于10.0.0.1:0.0 ,其中10.0.0.1是你的IP地址(我不确定0.0是什么,但0.0通常有效)。
You also need some X server software to run on your PC, which would show the window. 您还需要一些X服务器软件才能在您的PC上运行,这将显示窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM