February 20, 2019

Multi-Head Displays in Linux - page 3


  • June 19, 1999
  • By Will Weisner
As far as running applications goes, multi-head setups are identical to a normal X server. All the apps which work normally in X will run fine. The main difference is that you control which monitor (also known as a "screen" or "display"), the application will appear on. Once you designate a display for that application to use, it must remain there until it exits.

Most programs designed to run in X take a command line argument that tells them which display to appear on. This usually takes the form of:

command -display 0.x

where x is the number of the screen (The default screen is usually 0.0, followed by 0.1 for the second screen, 0.2 for the third, etc.). This can differ from application to application; for example, a program which uses the GTK widget set has a syntax like this:

command --display 0.x

whereas a program in the GNOME desktop environment can take the command like this:

command --display=0.x

When in doubt, consult the main page or other online documentation for the command. Sometimes it's not possible to tell a program which display you would like it to use on the command line. For these situations, you can use the DISPLAY environment variable, which will supersede anything else. To do that, write a shell script like this:

#Set the variable to the desired display, in this case screen 2
export DISPLAY=:0.1

#This is an example command
exec xcalc

Note that environment variables are passed down to child processes when they are spawned. What this means in a practical sense is that if you have an xterm on monitor number two, all the programs you run from that xterm will appear on monitor two by default, regardless of command line switches.

Window managers work in much the same way as normal programs, except that some window managers such as Window Maker and FVWM will take over all the available screens automatically. Others, such as IceWM, require you to run a new instance of the server with the -display switch for every screen. This allows you to perform nifty tricks, such as running a different kind of window manager on each monitor!

Most Popular LinuxPlanet Stories