Skip to content

Archives

Using VNC For Your Main Desktop

I’ve just fixed my desktop machine (had to buy a new CPU, unfortunately, after the old one died during shipping).

I then upgraded to Red Hat 9 (woo, very nice), switched to KDE for my desktop, and took a look at software suspend (because the machine is too noisy to leave on permanently in the corner of the living room).

However, the latter won’t work with my video card; instead, the machine reboots continually when resuming from suspend. Problem.

A bit of thinking about the problem came up with a nifty solution… I’d heard of folks using a VNC server for their main desktop, in order to connect to it from any machine they found themselves near, and not be ‘tethered’ to one particular desktop machine. The same system also means I can run my desktop with a virtual display, and just ‘connect’ to this from the real one. Then, when I want to suspend, I can just kill off the X server, suspend, and start up a new one after resume.

If you’re curious about how to do this, read on

From: Justin Mason
Subject: setting up a VNC desktop

Software suspend won’t work with my video card; instead, the machine reboots continually when resuming from suspend. Problem.

A bit of thinking about the problem came up with a nifty solution… I’d heard of folks using a VNC server for their main desktop, in order to connect to it from any machine they found themselves near, and not be ‘tethered’ to one particular desktop machine. The same system also means I can run my desktop with a virtual display, and just ‘connect’ to this from the real one. Then, when I want to suspend, I can just kill off the ‘hardware’ X server, suspend, and start up a new one after resume.

First, install xf4vnc. This gives you a VNC server that can use the ‘Render’ extension, and therefore display anti-aliased text efficiently. Installation of this is a bit of a manual job, unfortunately, since the author hasn’t actually packaged it in any way. Not too hard though; just 3 copy commands; I don’t think you actually need any files apart from the two in the xf4vnc-linux-i386 group.

Create a file called ~/.xserverrc containing:

:: /usr/local/bin/Xvnc-xf4vnc -depth 16 -geometry 1152×864 -deferupdate 10 :0

Best to make the depth and geometry match your current display.

Next, create a script called ~/bin/x containing:

:: #!/bin/sh
:: X :1 &
:: sleep 4
:: vncviewer -compresslevel 0 -quality 9 -fullscreen -display :1 localhost:0

(ie. start an X display on :1, then display vncviewer to that display.) Don’t forget to make it executable with chmod.

Now, close your current X desktop, return to the console, and run startx to start a new one. This won’t display; instead, it’ll run GNOME/KDE/whatever using a virtual framebuffer. CTRL-Z and bg that process.

Run the x script. It’ll connect to your virtual desktop. That’s it!

You can now hit CTRL-ALT-Backspace to your heart’s content. When your display is killed, the applications and desktop remain untouched. When you rerun the x script, it’ll reconnect and nothing will have changed apart from the mouse pointer position. In fact, I just restarted my X server halfway through that sentence ;)

Have fun!