tags:

views:

196

answers:

6

X Power Tools -book has a sentence about ":0":

Display 0 on the local computer, connected by a local connection scheme

I tried to open a clock by "xclock -display :2", but I got an error:

Can't open display: :2

How am I supposed to program if I cannot get displays working? Can you really do everything on it? How can you run programs, such as Vim and gcc, on displays 3 and 999? Where are they?

A: 

Don't worry about using other displays at first. Probably the only time you'll have to worry about displays is when you connect to a remote computer and connect your remote applications to the display.

Your applications that you write won't have to directly worry about the display; the X library will take care of it for you.

lacqui
+4  A: 

It has to do with the X Window Server. They define what display numbers there are.

You shouldn't need to worry about explicitly supporting a display number; at the very most, you simply hand the reference to the X Window Client library and let it figure it out.

Modern servers can make multiple displays available with multi-head adapters and with multiple adapters. The vast majority of the time, :0 will be your only display. This is because there really is only one, and that's the default number when there is just one. It is possible to make it start as :2, which is unusual, but everything would still work okay.

With multi-head displays and/or multiple cards, it is possible to have an X Server manage multiple displays as discrete screens (i.e. with things like Xinerama turned off). Then you can get display numbers like :0.0 and :0.1. I used to run a desktop like this for a long time. Nothing broke because everything took the display number and just handed it to the X Client library. One unusual advantage was that each screen gets it's own list of virtual desktops. In a Xinerama display, you can't do that. But you have the disadvantage of not being able to move windows between screens, because they have different display numbers.

You can even do things like run multiple X Servers. That's when you get :0 and :1 etc. The problem with that is who gets the keyboard and mouse.

staticsan
vnc also uses :1,:2,etc.
Alex B
I was going to mention that, but it didn't fit when I first thought of it and then I forgot later.
staticsan
Ont time I've run a X11 server in a Mac emulator (http://en.wikipedia.org/wiki/Macintosh_Application_Environment) on a Sun workstation. I could put an xterm in native Sun workspace with :0 and another in the Mac emulator with :1.
mouviciel
A: 

You can only access the displays that exist on your computer (usually only one 0). However there are programs that can create new displays as windows like xnest.

But lacqui and staticsan are right, most of the time you don't care about displays.

For more information go and read about the X Window System.

lothar
A: 

I do in fact run two X servers (some X program I use doesn't like modern window managers).

In my setup, they each get a VTERM and the active one has keyboard and mouse.

Joshua
+1  A: 

By default a machine will normally only be running one display - :0, which is normally on VT 7.

If you run a second X server, it will be :1. You can do that from the command line, but the easier way is to choose "start new session" in KDE (I assume GNOME has some equivalent, but I'm not familiar with it). That lets you log in again on a second X server, which will be running on VT 8 (ie. you can swap between them with Ctrl-Alt-F7 and Ctrl-Alt-F8).

You should then be able to run applications on either by using "DISPLAY=:1 xterm" or whatever.

Peter
A: 

The user staticsan told about a problem:

You can even do things like run multiple X Servers. That's when you get :0 and :1 etc. The problem with that is who gets the keyboard and mouse.

I was interested why exactly it becomes a problem "who gets the keyboard and mouse". I found the answer in the article, recommend by the user Charlie Martin, in my other question at [1]:

an individual display is defined by the X11 documentation as having exactly one keyboard and one pointer (i.e., mouse), but potentially multiple CPUs, monitors, etc.

[1] http://stackoverflow.com/questions/746263/how-do-the-server-extensions-work-in-x/746286#746286

Masi