BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Fun with Xorg
Pages: 1, 2

Distributed Multihead

One of X's design goals was to work in a networked environment, so there are several cool things you can do if you have access to multiple systems running X. It is remarkably easy for X systems to share display information, so I recommend performing these experiments within a home LAN behind an internet firewall.



One experiment allows you to spread a single display across multiple monitors using DMX (Distributed Multihead X). Start by installing the package on all the systems that will share the display:

# pkg_add -r xorg-dmx

For security reasons, FreeBSD systems don't participate on an X network by default, so temporarily change this behavior. Close any open X sessions and restart X with the option:

% startx -listen_tcp

Verify that X is listening on the network:

# sockstat -4 | grep Xorg
root    Xorg    33811 1  tcp4   *.6000    *.*

Now that X is listening, you have to tell it to accept incoming connections. The lazy approach is to run on all the systems:

% xhost +
access control disabled, clients can connect from any host

This message means exactly that; anyone can connect to your X display, which is why a firewall between you and the internet is important. It makes more sense to allow only the specific IP(s) of the systems you are experimenting with:

% xhost -
access control enabled, only authorized clients can connect

% xhost +192.168.1.1
192.168.1.1 being added to access control list

% xhost
access control enabled, only authorized clients can connect
INET:192.168.1.1

A good place to start is with an example of sharing a display between two monitors. 192.168.1.1 has the desktop I wish to display and 192.168.1.2 is the second system. I have configured both systems to accept X connections from each other.

From the GUI on 192.168.1.1, I run the command:

% startx -- /usr/X11R6/bin/Xdmx :1 -display 192.168.1.1:0 -display \
192.168.1.2:0 +xinerama -noglxproxy

Note that this is one long command. Don't include the \ when you type it in. You'll also receive an error if you don't give the full path name to Xdmx.

This command starts a new shared display (:1) that overrides the current display on both systems. The server will accept keyboard and mouse input from the first IP address, but it will work on either monitor. If you move your mouse, it can move onto the second monitor. While there, you can right-click on the second monitor and change the wallpaper for the entire display. When you wish to go back to your original displays, press Ctrl-Alt-Backspace. Any changes that you made in the shared display won't affect the two original displays.

man Xdmx provides many options for experimentation. A Developer Works article entitled "Distributed Multihead Support with Linux and Xdmx" contains instructions for adding monitors vertically, as well as some good troubleshooting tips.

Monitor Other Systems

Once you've configured systems to allow X connections from each other, it is trivial to monitor activity on other systems. I installed a watcher program on 192.168.1.1:

# pkg_add -r xwatchwin

Every time a window (or window manager) opens in X, it receives a window ID. In order to watch another system, you need to know the ID of the window you wish to view. As an example, if I want to watch 192.168.1.2's KDE session, from 192.168.1.2's GUI, I can determine the window ID by typing:

% xwininfo
xwininfo: Please select the window about which you
      would like information by clicking the
      mouse in that window.

If I click the desktop, this is the first line of output:

xwininfo: Window id: 0x1200008 "KDE Desktop"

In this case, "KDE Desktop" is the window ID. It is worth noting that the default window ID names are easily guessable. This is the reason why we use firewalls and why X shouldn't listen on the network by default.

I can watch everything that happens during that remote KDE session by typing one command on 192.168.1.1:

% xwatchwin -u 1 192.168.1.2 KDE Session

The update switch (-u 1) will refresh the display every second. Figure 2 shows the result.

Thumbnail, click for full-size image.
Figure 2. Watching a remote window (click for full-size image)

Conclusion

If you found this article interesting, read man X (note the capital X), which details many of the programs that come with the X window manager. Each of these will run easily on your own system, but you may have to delve a bit deeper into man Xsecurity if you want to experiment with other systems within your firewall-protected network.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.


Return to the BSD DevCenter.



Sponsored by: