Setting up and using VNC
VNC
(Virtual Network Computing) is used to display a desktop from one
machine on another machine.
The original VNC is available from RealVNC.
This is what I used under Slackware 11, and it works fine. However, TightVNC is distributed with
Slackware 13, and offers better compression - so this is what I now use.
Although TightVNC is distributed with Slackware 13, it is in the
"extra" directory and is not installed by default. You can download it
from the UK
Mirror Service and install it using installpkg. I've already
installed it on sage, so if you want to view a desktop from sage on
your laptop, you just need to install VNC on the laptop.
Starting a server
Use the 'vncserver'
command to start a VNC server on the machine whose desktop you want to
display. For example:
ssh
sage
vncserver
This starts up a special X server that doesn't connect to a real
display, but instead allows remote VNC clients to connect to it. You
can start multiple VNC servers - each will have a different "display
number" associated with it. vncserver
tells you the assigned display number when it starts. If you have a
real X server running, that will be display :0, so the first VNC server
will be display :1, the second will be :2, and so on.
To kill a VNC server, use the vncserver
command with the '-kill'
option. You have to specify the display number, e.g.:
vncserver -kill
:1
You can give various options to the vncserver command - see the vncserver and Xvnc man pages for details.
What the man page doesn't tell you is how to put these options in the ~/.vnc/tightvncserver.conf
configuration file. By examining /usr/bin/vncserver
(which is a Perl script) I discovered that the configuration file
should contain Perl assignment statements! For example, you could set
the geometry using the following configuration file:
# Example Tight
VNC configuration file
$geometry = "1280x960";
When you first run vncserver
it will prompt you for a new password. This password is stored in ~/.vnc/passwd and can be
changed later using the vncpasswd command. If you don't want to enter a
password whenever you run vncviewer,
you can disable password protection by putting the line '$authType = "";' in the ~/.vnc/tightvncserver.conf configuration
file.
vncserver uses the file ~/.vnc/xstartup to initialize
the X server. If the file doesn't exist when you first start vncserver, a default one will
be created. The default xstartup
executes /etc/X11/xinit/xinitrc,
which should give you an Xfce desktop.
I've edited my ~/.vnc/xstartup
to keep the VNC Xfce configuration separate from the normal Xfce
configuration, and also to save any X/Xfce output to a log file:
#!/bin/sh
# Trace shell commands
set -x
# Keep Xfce configuration separate from normal desktop
export XDG_CONFIG_HOME=/home/fog/.vnc/.config
# Turn off beep
xset b off
# Start the desktop, logging any output
exec /etc/X11/xinit/xinitrc &> ~/.vnc/xfce.log
vncserver sends its log
output to the file ~/.vnc/sage:1.log
(for example), which may be useful for diagnosing problems.
Starting a client
Use the 'vncviewer'
command (on your laptop, for example) to connect to the VNC server. You
need to specify the host and display number, e.g.:
vncviewer
sage:1
You can give various options to the vncviewer command - see the man
page for details.
If you have images displayed on the desktop that you are viewing, it
may help to increase the compression level. For example:
vncviewer
-compresslevel 4 sage:1
Check that you are not loading sage too heavily if you do increase the
compression level.
Connecting to the real X server
There may be occasions when you want to view/use the desktop that is
being displayed by the real X server, rather than a virtual desktop
created by vncserver. The x11vnc
server enables you to do this.
x11vnc isn't in the Slackware distribution, but is easy to build (./configure; make; make install
DESTDIR=...).
I've installed x11vnc on
sage, and start it automatically from ~fog/.xinitrc. Configuration of
x11vnc is in the file ~fog/.x11vncrc:
# Connect to the usual X server.
-display :0
# Scale down so that sage's
high-resolution screen will fit in a window on
# a laptop display.
-scale 3/4
# Run in the background
-bg
# Keep running even if no clients
are connected.
-forever
# Allow more than one
simultaneous client
-shared
# Send output to a log file
-o /home/fog/.vnc/x11vnc.log
# Don't bother monitoring for
beeps
-nobell
# Don't use the XDAMAGE feature
for monitoring for changes - it doesn't work
# properly (sage is probably
using "compiz").
-noxdamage
To connect to the x11vnc
server you simply specify display :0 in the vncviewer command:
vncviewer
sage:0
When connected to the real desktop you should obviously be careful to
not interfere with other uses of the desktop (e.g. MythTV, someone
using the real display/keyboard, ...).