Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

x11 - How can I specify a display?

When I run some programs over SSH, such as firefox &, I get an error

Error: no display specified 

I would like to open many displays, still showing the stdout of each program.

Initial Question: How can I specify the display to get a many-displayed program?

Pablo Santa Cruz gives me the following code as a solution. I do not understand it.

$ export DISPLAY=yourmachine.yourdomain.com:0.0

$ firefox &

What are yourmachine and yourdomain.com in the command?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The way that X works is the same as the way any network program works. You have a server of some description (in this case, the X display server) which runs on a specific machine, and you have X clients (like firefox) that try to connect to that server to get their information displayed.

Often (on "home" machines), the client and server run on the same box and there's only one server, but X is powerful enough that this doesn't need to happen. It was built with the server/client separation built in from the start.

This allows you to do such wondrous things such as log on to your box (in text mode) halfway around the planet, tell it that the display server is the box you're currently on and, voila, the windows suddenly start appearing locally.

In order for a client to interact with a user, it needs to know how to find the server. There are a number of ways to do this. Many clients allow the -display or --displayoption to specify it:

xeyes -display paxbox1.paxco.com:0.0

Many will use the DISPLAY environment variable if a display isn't specifically given. You can set this variable like any other:

DISPLAY=paxbox1.paxco.com:0.0; export DISPLAY # in .profile
export DISPLAY=paxbox1.paxco.com:0.0 # in your shell
DISPLAY=paxbox1.paxco.com:0.0 firefox & # for that command (shell permitting)

The first part of the DISPLAY variable is just the address of the display server machine. It follows the same rule as any other IP address; it can be a resolvable DNS name (including localhost) or a specific IP address (such as 192.168.10.55).

The second part is X-specific. It gives the X "display" (X server) number and screen number to use. The first (display number) generally refers to a group of devices containing one or more screens but with a single keyboard and mouse (i.e., one input stream). The screen number generally gives the specific screen within that group.

An example would be:

+----------------------------------------+
|paxbox1.paxco.com|                      |
+-----------------+                      |
|                                        |
|  +----------+----+  +----------+----+  |
|  |Display :0|    |  |Display :1|    |  |
|  +----------+    |  +----------+    |  |
|  |               |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.0| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.1| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.2| |  | |Screen :1.0| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.3| |  | |Screen :1.1| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | | Keyboard  | |  | |  Keyboard | |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |   Mouse   | |  | |   Mouse   | |  |
|  | +-----------+ |  | +-----------+ |  |
|  +---------------+  +---------------+  |
|                                        |
+----------------------------------------+

Here you have a single machine (paxbox1.paxco.com) with two display servers. The first has four screens and the second has two. The possibilities are then:

DISPLAY=paxbox1.paxco.com:0.0
DISPLAY=paxbox1.paxco.com:0.1
DISPLAY=paxbox1.paxco.com:0.2
DISPLAY=paxbox1.paxco.com:0.3
DISPLAY=paxbox1.paxco.com:1.0
DISPLAY=paxbox1.paxco.com:1.1

depending on where you want your actual windows to appear and which input devices you want to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...