Google

Net Neutrality Canada - Neutrality.ca
Save the Net

This (rather old, re-posted) article explains how to set up an X desktop session that can be detached and reattached like GNU screen handles terminals. As an added benefit, it can be remote controlled from another X terminal (giving features similar to a dual-headed display), and the display can be shared among multiple viewers (for example, in a classroom).

This is actually quite simple. You'll need the VNC package from RealVNC. The Unix version of VNC includes an X11 server called Xvnc, which exports X11 protocol to X clients and the RFB (VNC) protocol to a VNC viewer. It does not provide any real framebuffer or video output.

You will also need a regular X server for your video hardware if you want a local display.

Here's what you do:

  • Set up the Xvnc server to run on display :0. You'll need to edit the vncserver shell script that comes with the VNC distribution. Set up your desired resolution, color depth, etc. It's generally a good idea to set up a password on your session. VNC's authentication is weak but better than none at all. You can get better security by tunnelling VNC over SSH and using host-based access control. Edit the VNC xsession script to start your desired clients and desktop. (I just run startkde.)
  • Now set up a real X display on display :1. It should have the same resolution and color depth as your virtual X server. Once you have that working, set up your .xinitrc or system-wide xinitrc file to run just a full-screen vncviewer and no other clients (not even a window manager). I disable the local keyboard and mouse on my vncviewer and use it strictly as a display, remote-controlling the screen from my laptop keyboard and mouse. You don't have to do that :) I also force it to be a shared viewer, so it doesn't detach automatically if another client connects. You may or may not want that.
  • If you want to remote-control the display from another terminal's keyboard and mouse, you can run something like Win2VNC to control it from Windows, or X2VNC to control it from X.

Now, the cool stuff. Since the X display (:0) where all your desktop clients run is actually a VNC server, you can attach any VNC compatible viewer from any machine and access your desktop. You can go home and ssh in to your work system, bring up a vncviewer and have your desktop just as you left it. You can be at a client's office and do the same thing. Conversely, you could connect home from your office and do something on your home machine. Your whole X desktop's state will be persistent no matter where you view it from. Even cooler is that the VNC server can run a tiny web server and let you access your desktop from any Java-enabled browser!

Since you can have shared VNC sessions, you can use this to do screen sharing and demos. Any number of people can connect.

There's only one drawback to this solution, but I find it very usable anyway. Xvnc doesn't support some extensions, like XFree86's DRI. Vmware won't run in fullscreen under it. I haven't had any real problems due to this, but it might be an issue for people who do heavy graphics or the like.