I am new to shell scripting. I don't understand what the $DISPLAY
environmental variable is.
I have Ubuntu 13.10 and I use /bin/bash
shell. I have two monitors.
Questions:
-
Command
echo $DISPLAY
will print:0.0
on my machine (on both monitors). What does this mean? -
In which cases will the
$DISPLAY
variable be blank or NULL? -
Are there any articles or tutorials on this?
Best Answer
The magic word in the X window system is DISPLAY. A display consists (simplified) of:
A display is managed by a server program, known as an X server. The server serves displaying capabilities to other programs that connect to it.
The remote server knows where it has to redirect the X network traffic via the definition of the DISPLAY environment variable which generally points to an X Display server located on your local computer.
The value of the display environment variable is:
where:
hostname is the name of the computer where the X server runs. An omitted hostname means the localhost.
D is a sequence number (usually 0). It can be varied if there are multiple displays connected to one computer.
S is the screen number. A display can actually have multiple screens. Usually, there's only one screen though where 0 is the default.
Example of values
hostname:D.S
means screen S on display D of host hostname; the X server for this display is listening at TCP port 6000+D.host/unix:D.S
means screen S on display D of host host; the X server for this display is listening at UNIX domain socket /tmp/.X11-unix/XD (so it's only reachable from host).:D.S
is equivalent to host/unix:D.S, where host is the local hostname.:0.0 means that we are talking about the first screen attached to your first display in your local host
Read more here: support.objectplanet.com and here: superuser.com and here: docstore.mik.ua.
From a X(7) man page: