LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What is the purpose of the DISPLAY environment variable? (https://www.linuxquestions.org/questions/linux-general-1/what-is-the-purpose-of-the-display-environment-variable-843780/)

anidev 11-11-2010 07:25 PM

What is the purpose of the DISPLAY environment variable?
 
I have seen that many GUI programs have a command line argument like --display. I found out that if no such argument is specified, the DISPLAY environment variable is used to determine which X server the program should connect to. I always thought that the display manager such as gdm or kdm connects directly to the X server, and that other programs should connect to the display manager. So now I am a little confused. Could anyone explain to me why programs connect directly to X servers, why use display managers if the above is the case, and what exactly happens when a window is made visible?

Thanks

neonsignal 11-11-2010 07:53 PM

The function of the display manager is to manage the X server instances, not to mediate the applications. The applications communicate directly to the X server.

So it is quite possible to run X without a display manager (and on an old system, is a good way to save some memory!). It is just a matter of calling xinit directly with appropriate parameters.

You can even do without a windows manager for that matter, if you don't need to shuffle windows around, for example when creating a kiosk platform.

mf93 11-11-2010 07:54 PM

all a windows manager does is give a display window for the Xserver to render TO. Xserver is in charge of all display rendering. The DISPLAY variable tells which display to which to send the rasterized image, which is usually at :0. for example, if you were to install xserver-xorg on an ubuntu box that had no window manager installed, and then sshed into it from a box WITH a window manager with the -X (X11 forwarding) option set, and entered a command such as xlogo, you would receive an xlogo window on the client machine, even though the server does not have a window manager installed.

frieza 11-11-2010 09:09 PM

as said before, the DISPLAY variable is to help sort out multiple instances of the X server (such as in a dual head situation the left monitor may be :0.0 and the right may be :0.1, or a multi seat situation, seat 1 may be :0 seat 2 :1 seat 3 :2 etc..., another example would be using Xephyr or Xnest to run a nested X session within another X session the main one would be :0 the second would be :1, and last but not least VNC would also use separate DISPLAY environments for each instance of VNC server) these are only a few examples

that being said you can also from the command line with some programs implicitly tell a program to start on a given display using something like --display :X(.x) or -display :X(.x) assuming your user account has privileges to USE the specified display.

anidev 11-12-2010 07:55 PM

OK, let me get all this info straight!

X is a program that runs on the computer very soon after the kernel loads. Almost all graphics that must be displayed on the monitor are sent to the X server. Other programs send their GUI images and other window info to the X server. The desktop manager contains information about what programs should startup, what the desktop should look, etc. and sends images to X also. The window manager manages switching between windows, z-ordering of windows, what gets painted and what doesn't, where windows are, etc. And then there is the compositing manager, which I guess intercepts or intervenes between the programs and X and offers an API for manipulating the image(s) before they are sent to the X server.

Did I get all that right?

neonsignal 11-12-2010 08:12 PM

Just a small terminology clarification: the "desktop manager" refers to the program that starts the X server (usually all you see of it is the username/password prompt). The look and feel of the desktop revolves more around what is called the "desktop environment", which is a loose term encompassing the look of the desktop and the various programs that provide menus, file browsing, settings, and so on.

The X server does start towards the end of the initialization on a desktop distro, but it is typically invoked by the desktop manager (eg gdm, kdk, or xdm).

frieza 11-13-2010 11:37 AM

one more clarification, the X server does not have to be running on the same machine, there are X servers for windoze as well, in that case you run the X server, connect to a remote machine (usually with SSH with X forwarding enabled) and then you can run remote X programs from that machine on the local X server, in this manner X11 is a reverse client server since the SERVER program runs locally and the clients are run remotely, yes its confusing but thats how it works

anidev 11-14-2010 11:55 AM

I think I understand most of it now. I read somewhere that X really is a server that runs in the background and clients connect to it through sockets. Usually the X server on the client machine and is accessed via the loopback network interface. This is, I believe, an X server can be run on a remote computer and be displayed on a remote computer.

One more question: I know that this is how an X server is referenced:
host:x.y
The "host" is the server computer (usually 127.0.0.1, localhost, or blank) and "x" is the instance of the X server running on the "host", but what is "y"?

frieza 11-15-2010 11:06 AM

y is the screen such as in multi-head set-ups :0.0 would be screen 1, :0.1 would be screen 2 etc.., however when using Xinerama for instance :X.1 to .X.n are transparently merged and all behave one virtual screen, :X.0

anidev 11-15-2010 09:38 PM

so "y" refers to each screen, which usually is a monitor.

Thanks for all your help! I'm glad I finally joined LQ...

frieza 11-16-2010 11:39 AM

your welcome, and yes it often represents a monitor but also it could be a virtual display such as with Xnest or Xephyr or vnc, and welcome to lq btw i forgot to say that the first time i replied

mf93 11-16-2010 07:06 PM

make sure you mark the thread as solved. thread tools(top right corner of original post)->mark thread as solved


All times are GMT -5. The time now is 11:53 PM.