x11vnc: -rawfb, -pipeinput, -xtrap, -flag, ...

runge 18 years ago
parent ac01f36ce0
commit baee5e2b3a

@ -1,3 +1,7 @@
2005-04-10 Karl Runge <runge@karlrunge.com>
* configure.ac: add mmap
* x11vnc: -rawfb, -pipeinput, -xtrap, -flag, ...
2005-04-03 Karl Runge <runge@karlrunge.com>
* configure.ac: add conditional libXTrap checking
* x11vnc: use DEC-XTRAP on old X11R5 for grab control.

@ -266,7 +266,7 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mkfifo select socket strchr strcspn strdup strerror strstr setsid getpwuid getpwnam getuid geteuid setuid waitpid setutxent])
AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mmap mkfifo select socket strchr strcspn strdup strerror strstr setsid getpwuid getpwnam getuid geteuid setuid waitpid setutxent])
# check, if shmget is in cygipc.a
@ -295,6 +295,7 @@ AC_CONFIG_FILES([Makefile

@ -1,6 +1,6 @@
cd "$(dirname "$0")"

@ -1,3 +1,13 @@
2005-04-10 Karl Runge <runge@karlrunge.com>
* -rawfb non X-polling (i.e. shm, mmap, lseek).
* -pipeinput enable external user input processing command.
* -xtrap use XESimulateXEventRequest to inject user input.
* scaling blend for StaticGray, add :fb scaling option.
* default password macros.
* improve -norepeat use under -viewonly.
* -flag flagfile to aid wrapper scripts.
* add utility scripts, etc. dir ./misc
2005-04-03 Karl Runge <runge@karlrunge.com>
* try DEC-XTRAP on X11R5 if XTestGrabControl is missing.
* -shiftcmap n, for 8bpp displays using < 256 color cells

@ -1,6 +1,9 @@
LDADD = ../libvncserver/libvncserver.a @WSOCKLIB@
SUBDIRS = misc
EXTRA_DIST=ChangeLog README tkx11vnc $(man_MANS)

@ -1,5 +1,5 @@
x11vnc README file Date: Sun Apr 3 16:28:59 EDT 2005
x11vnc README file Date: Sun Apr 10 00:24:10 EDT 2005
The following information is taken from these URLs:
@ -97,15 +97,22 @@ x11vnc: a VNC server for real X displays
You could have also set the environment variable DISPLAY=:0 instead of
using -display. This step attaches x11vnc to the far-away.east:0 X
display (no viewer clients yet).
display (i.e. no viewer clients yet).
To get X11 permissions right, you may also need to set the XAUTHORITY
environment variable (or use the [12]-auth option) to point to the
correct MIT-MAGIC-COOKIE file (e.g. /home/joe/.Xauthority). More on
this [13]below.
There will then be much chatter printed out from x11vnc, until it
finally says something like:
If you suspect an X11 permissions problem do this simple test: while
sitting at the physical X display open a terminal window
(gnome-terminal, xterm, etc). You should be able to start x11vnc
without any need for command line options in that terminal. If that
works OK then you know X11 permissions are the only thing preventing
it from working when you try to start x11vnc via a remote shell.
When x11vnc starts up there will then be much chatter printed out,
until it finally says something like:
13/05/2004 14:59:54 Autoprobing selected port 5900
@ -1021,14 +1028,24 @@ make
specify it. Nearly always the correct value will be ":0"
For the latter error, you need to set up the X11 permissions
correctly. See the xauth(1), Xsecurity(7), and xhost(1) man pages for
much info. For example, you may need to set your XAUTHORITY
environment variable or use the [142]-auth option to point to the
correct cookie file (e.g. /home/joe/.Xauthority or /var/gdm/:0.Xauth),
or simply be sure you run x11vnc as the correct user (i.e. the user
who owns the X session you wish to view). Running x11vnc as root is
not enough: you need to know where the XAUTHORITY file for the desired
X display is. Example:
To make sure X11 permissions are the problem do this simple test:
while sitting at the physical X display open a terminal window
(gnome-terminal, xterm, etc). You should be able to start x11vnc
without any need for special steps or command line options in that
terminal. If that works OK then you know X11 permissions are the only
thing preventing it from working when you try to start x11vnc via,
say, a remote shell.
How to Solve: See the xauth(1), Xsecurity(7), and xhost(1) man pages
for much info on X11 permissions. For example, you may need to set
your XAUTHORITY environment variable or use the [142]-auth option to
point to the correct cookie file (e.g. /home/joe/.Xauthority or
/var/gdm/:0.Xauth), or simply be sure you run x11vnc as the correct
user (i.e. the user who owns the X session you wish to view). Running
x11vnc as root is not enough: you need to know where the XAUTHORITY
file for the desired X display is. Example:
x11vnc -display :0 -auth /var/gdm/:0.Xauth
Less safe, but to avoid figuring out where the XAUTHORITY file is, if
@ -1036,24 +1053,26 @@ make
should be able to attach x11vnc to the session (from the same
machine). The person could then type "xhost -localhost" after x11vnc
has connected to go back to the default permissions. Also, for some
situations the -users lurk= option may be of use (please read the
situations the "-users lurk=" option may be of use (please read the
documentation on the [143]-users option).
To test out your X11 permissions, set DISPLAY and possibly XAUTHORITY
(see your shell's man page, bash(1), tcsh(1), on how to set
environment variables) and type xdpyinfo in the same place you will be
typing (or otherwise running) x11vnc. If information is printed out
about the X display (screen sizes, supported extensions, color visuals
info) that means the X11 permissions are set up properly: xdpyinfo
successfully connected to DISPLAY. You could also type xclock and make
sure no errors are reported (a clock should appear on the X display,
type Ctrl-C to quit it)
To test out your X11 permissions from a remote shell, set DISPLAY and
possibly XAUTHORITY (see your shell's man page, bash(1), tcsh(1), on
how to set environment variables) and type xdpyinfo in the same place
you will be typing (or otherwise running) x11vnc. If information is
printed out about the X display (screen sizes, supported extensions,
color visuals info) that means the X11 permissions are set up
properly: xdpyinfo successfully connected to DISPLAY! You could also
type xclock and make sure no errors are reported (a clock should
appear on the X display, press Ctrl-C to stop it). If these work, then
typing "x11vnc" should also work.
Important: if you cannot get your X11 permissions so that the xdpyinfo
or xclock tests work, x11vnc also will not work (all of these X
clients must be allowed to connect to the X server to function
Q-2: I can't get x11vnc and/or libvncserver to compile.
Make sure you have all of the required -devel packages installed.
@ -1092,6 +1111,7 @@ make
Q-3: I just built x11vnc successfully, but when I use it my keystrokes
and mouse button clicks are ignored (I am able to move the mouse
@ -1131,6 +1151,7 @@ h
20/03/2005 22:33:09 No XTEST extension, switching to -xwarppointer mode for
20/03/2005 22:33:09 pointer motion input.
Q-4: Help, I need to run x11vnc on Solaris 2.5.1 (or other old
Unix/Linux) and it doesn't compile!
@ -1177,6 +1198,7 @@ typedef unsigned int in_addr_t;
it worked or not). If there is enough demand we will try to push clean
compilations back to earlier Solaris, Linux, etc, releases.
Q-5: Where can I get a precompiled x11vnc binary for my Operating
@ -1225,6 +1247,7 @@ typedef unsigned int in_addr_t;
resulting data.tar.gz tar file. Also, rpm2cpio(1) is useful in
extracting files from rpm packages.
Q-6: Where can I get a VNC Viewer binary (or source code) for the
Operating System I will be viewing from?
@ -1234,6 +1257,7 @@ typedef unsigned int in_addr_t;
* [156]http://www.realvnc.com/download-free.html
* [157]http://sourceforge.net/projects/cotvnc/
Q-7: How can I see all of x11vnc's command line options and
documentation on how to use them?
@ -1241,6 +1265,7 @@ typedef unsigned int in_addr_t;
-help for long descriptions about each option. The output is listed
[158]here as well.
Q-8: I don't like typing arcane command line options every time I
start x11vnc. What can I do? Is there a config file? Or a GUI?
@ -1275,6 +1300,7 @@ display :0
"x11vnc ... -gui other:0" in the latter case the gui is displayed on
other:0, not the X display x11vnc is polling.
Q-9: Can I make x11vnc more quiet and also go into the background
after starting up?
@ -1284,6 +1310,7 @@ display :0
Note that under -bg the stderr messages will be lost unless you use
the "[162]-o logfile" option.
Q-10: Sometimes when a VNC viewer dies abruptly, x11vnc also dies with
the error message like: "Broken pipe". I'm using the -forever mode and
I want x11vnc to keep running.
@ -1297,6 +1324,7 @@ display :0
[163]x11vnc.c file. It also has an [164]option -sigpipe exit to have
x11vnc clean up and exit upon receiving SIGPIPE.
Q-11: Are there any build-time customizations possible, e.g. change
defaults, create a smaller binary, etc?
@ -1318,6 +1346,14 @@ display :0
If other things (e.g. "-I ...") are needed in CPPFLAGS add them as
Be careful the the following two variables: HARDWIRE_PASSWD and
HARDWIRE_VIEWPASSWD. If set (remember to include the double quotes
around the string), they will be used as default values for the
-passwd and -viewpasswd options. Of course the strings will exist
unobscured in the x11vnc: the binary better not be readable by
unintendeds. Perhaps this is of use in remote access for an embedded
application, etc...
Let us know if more build-time customizations would be useful.
If the system does not have the XTEST XTestGrabControl interface (some
@ -1357,6 +1393,7 @@ display :0
All of them will work with x11vnc (except x2x where it is not needed).
Q-13: I am running Win2VNC on my Windows machine and "x11vnc -nofb" on
Unix to pass keyboard and mouse to the Unix monitor. Whenever I start
Win2VNC it quickly disconnects and x11vnc says:
@ -1401,6 +1438,7 @@ display :0
non-zero in 8bpp PseudoColor on an obscure setup, and this option
corrected the problems.
Q-15: Color problems: Why are the colors for some windows messed up in
x11vnc? BTW, my X display has nice overlay/multi-depth visuals of
different color depths: e.g. there are both depth 8 and 24 visuals
@ -1480,6 +1518,7 @@ TrueColor defdepth 24
[182]-overlay option works for Solaris machines with overlay visuals
where most of this problem occurs.
Q-16: How do I figure out the window id to supply to the -id windowid
@ -1498,6 +1537,7 @@ TrueColor defdepth 24
extracts the windowid. Besides "pick" there is also "id:root" to allow
you to go back to root window when doing remote-control.
Q-17: Why don't menus or other transient windows come up when I am
using the -id windowid option to view a single application window?
@ -1515,6 +1555,7 @@ TrueColor defdepth 24
x11vnc is known to crash under both -id and -sid, so both modes are
still experimental. Please report any reproducible bugs.
Q-18: My X display is depth 24 at 24bpp (instead of the normal depth
24 at 32bpp). I'm having lots of color and visual problems with x11vnc
and/or vncviewer. What's up?
@ -1673,6 +1714,7 @@ TrueColor defdepth 24
Alt. Alternatively, the [196]-clear_mods option and [197]-clear_keys
option can be used to release pressed keys at startup and exit.
Q-22: Can I change settings in x11vnc without having to restart it?
Can I remote control it?
@ -1718,6 +1760,7 @@ TrueColor defdepth 24
text (i.e. not obscured like the -rfbauth VNC passwords) password
Q-24: Can I have two passwords for VNC viewers, one for full access
and the other for view-only access to the display?
@ -1745,6 +1788,7 @@ TrueColor defdepth 24
plain text passwords from $HOME/.vnc/passwd since it is very
straight-forward to work out what to do from the VNC source code.
Q-25: Can I fine tune what types of user input are allowed? E.g. have
some users just be able to move the mouse, but not click or type
@ -1758,6 +1802,7 @@ TrueColor defdepth 24
These settings can also be applied on a per-viewer basis via the
remote control mechanism or the GUI. E.g. x11vnc -R input:hostname:M
Q-26: Why does x11vnc exit as soon as the VNC viewer disconnects? And
why doesn't it allow more than one VNC viewer to connect at the same
@ -1776,6 +1821,7 @@ TrueColor defdepth 24
apply these security measures, they will not be done for you
Q-27: Can I limit which machines incoming VNC clients can connect
@ -1794,6 +1840,7 @@ TrueColor defdepth 24
[216](tcp_wrappers) and then use /etc/hosts.allow See hosts_access(5)
for complete details.
Q-28: How do I build x11vnc/libvncserver with libwrap (tcp_wrappers)
@ -1814,6 +1861,7 @@ TrueColor defdepth 24
x11vnc with libwrap support because the /usr/sbin/tcpd reference in
/etc/inetd.conf handles the tcp_wrappers stuff.
Q-29: Can I have x11vnc only listen on one network interface (e.g.
internal LAN) rather than having it listen on all network interfaces
and relying on -allow to filter unwanted connections out?
@ -1830,6 +1878,7 @@ TrueColor defdepth 24
option [220]-localhost now implies "-listen localhost" since that is
what most people expect it to do.
Q-30: Now that -localhost implies listening only on the loopback
interface, how I can occasionally allow in a non-localhost via the
allowonce remote control command?
@ -1847,6 +1896,7 @@ TrueColor defdepth 24
in on the listening interface. If you just toggle [225]-localhost on
and off x11vnc should see to it that you never get into such a state.
Q-31: How can I tunnel my connection to x11vnc via an encrypted SSH
channel between two Unix machines?
@ -1857,6 +1907,7 @@ TrueColor defdepth 24
Other secure encrypted methods exists, e.g. stunnel, IPSEC, various
VPNs, etc.
Q-32: How can I tunnel my connection to x11vnc via an encrypted SSH
channel from Windows using an SSH client like Putty?
@ -1900,6 +1951,7 @@ TrueColor defdepth 24
5500 instead of 5900 (i.e. 'Source port: 5500' and
'Destination: localhost:5500' for a Remote connection).
Q-33: Can I prompt the user at the local X display whether the
incoming VNC client should be accepted or not? Can I decide to make
some clients view-only? How about running an arbitrary program to make
@ -1994,6 +2046,7 @@ exit 1
variables are set as in "-accept command" (except that RFB_MODE will
be "gone").
Q-34: Does x11vnc support Unix usernames and passwords? Can I further
limit the set of Unix usernames who can connect to the VNC desktop?
@ -2045,6 +2098,7 @@ exit 1 # reject it
For this to work with ssh port redirection, the ssh option
UsePrivilegeSeparation must be enabled.
Q-35: I start x11vnc as root because it is launched via inetd(1) or a
display manager like gdm(1). Can I have x11vnc later switch to a
different user?
@ -2056,6 +2110,7 @@ exit 1 # reject it
+nobody" that switches to the Unix user nobody right after connections
to the X display are established.
Q-36: I use a screen-lock when I leave my workstation (e.g.
xscreensaver or xlock). When I remotely access my workstation desktop
via x11vnc I can unlock the desktop fine, but I am worried people will
@ -2090,6 +2145,7 @@ exit 1 # reject it
obviously re-lock the screen before disconnecting!). Instructions can
be found in the source code for the utility at the above link.
Q-37: Can I have x11vnc automatically lock the screen when I
disconnect the VNC viewer?
@ -2138,6 +2194,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
plus any other options you desire.
Q-39: How can I use x11vnc to connect to an X login screen like xdm,
GNOME gdm, KDE kdm, or CDE dtlogin? (i.e. nobody is logged into an X
session yet).
@ -2279,6 +2336,7 @@ rever -bg
If the machine is a traditional Xterminal you may want to read
[253]this FAQ.
Q-40: Can I run x11vnc out of inetd(1)? How about xinetd(1)?
Yes, perhaps a line something like this in /etc/inetd.conf will do it
@ -2347,6 +2405,7 @@ service x11vncservice
With the contents of /usr/local/bin/x11vnc_sh similar to the example
given above.
Q-41: How do I make x11vnc work with the Java VNC viewer applet in a
web browser?
@ -2374,6 +2433,7 @@ service x11vncservice
entirely from the viewer-side by having the jar file there and using
either the java or appletviewer commands to run the program.
Q-42: Are reverse connections (i.e. the VNC server connecting to the
VNC viewer) using "vncviewer -listen" and vncconnect(1) supported?
@ -2401,6 +2461,7 @@ service x11vncservice
xprop -root -f VNC_CONNECT 8s -set VNC_CONNECT "$1"
Q-43: Can I use x11vnc as a replacement for Xvnc? (i.e. not for a real
display, but for a virtual one I keep around).
@ -2443,6 +2504,7 @@ xmodmap -e "add Control = Control_L Control_R"
One can use this sort of scheme to export other virtual X sessions,
say Xnest or even Xvnc itself (useful for testing x11vnc).
Q-44: How can I use x11vnc on "headless" machines? Why might I want
@ -2539,6 +2601,7 @@ ied)
done over local machine sockets it should be acceptable (see an
[265]earlier question discussing -noshm).
Q-46: How can I make x11vnc use less system resources?
The [266]-nap and "[267]-wait n" (where n is the sleep between polls
@ -2548,6 +2611,7 @@ ied)
[268]-onetile option will use less memory and use fewer shared memory
slots (add [269]-fs 1.0 for one less slot).
Q-47: How can I make x11vnc use MORE system resources?
You can try [270]-threads and dial down the wait time (e.g. -wait 1)
@ -2561,6 +2625,7 @@ ied)
the x11vnc [272]-id option) can be streamed over a LAN or wireless at
a reasonable frame rate.
Q-48: I use x11vnc over a slow link with high latency (e.g. dialup
modem), is there anything I can do to speed things up?
@ -2622,6 +2687,7 @@ ied)
* Use [282]-nocursor and [283]-nocursorpos (repainting the remote
cursor position and shape takes resources and round trips)
Q-49: When I drag windows around with the mouse or scroll up and down
things really bog down (unless I do the drag in a single, quick
motion). Is there anything to do to improve things?
@ -2648,6 +2714,7 @@ ied)
(try to get the viewers to use different VNC encodings, e.g. tight and
Q-50: Does x11vnc support the X DAMAGE Xserver extension to find
modified regions of the screen quickly and efficiently?
@ -2733,6 +2800,7 @@ ied)
apply a patch to your VNC Viewer to extract hidden alpha channel data
under 32bpp. [296]Details can be found here.
Q-52: When using XFIXES cursorshape mode, some of the cursors look
really bad with extra black borders around the cursor and other cruft.
How can I improve their appearance?
@ -2780,6 +2848,7 @@ ied)
-alpharemove to brighten them by having x11vnc divide out the alpha
Q-53: In XFIXES mode, are there any hacks to handle cursor
transparency ("alpha channel") exactly?
@ -2830,6 +2899,7 @@ ied)
CursorShapeUpdates) will be to draw the moving cursor into the x11vnc
framebuffer. This can also be disabled via -nocursor.
Q-55: Can I take advantage of the TightVNC extension to the VNC
protocol where Cursor Positions Updates are sent back to all connected
clients (i.e. passive viewers can see the mouse cursor being moved
@ -2839,8 +2909,9 @@ ied)
support the Cursor Positions Updates for the user to see the mouse
motions (the TightVNC viewers support this). As of Aug/2004 in the
libvncserver CVS -cursorpos is the default. See also [305]-nocursorpos
and [306]-nocursorshape.
and [306]-nocursorshape.
Q-56: Is it possible to swap the mouse buttons (e.g. left-handed
operation), or arbitrarily remap them? How about mapping button clicks
to keystrokes, e.g. to partially emulate Mouse wheel scrolling?
@ -2918,6 +2989,7 @@ ied)
[313]-debug_keyboard option prints out much info for every keystroke
and so can be useful debugging things.
Q-58: When I try to type a "<" (i.e. less than) instead I get ">"
(i.e. greater than)! Strangely, typing ">" works OK!!
@ -2978,6 +3050,7 @@ ied)
Note that the [317]-debug_keyboard option prints out much info for
every keystroke to aid debugging keyboard problems.
Q-59: I'm using an "international" keyboard (e.g. German "de", or
Danish "dk") and the -modtweak mode works well if the VNC viewer is
run on a Unix/Linux machine with a similar keyboard. But if I run
@ -3067,6 +3140,7 @@ ied)
when the Keysym is received from a VNC viewer, and only after that
would -add_keysyms, or anything else, come into play.
Q-60: When typing I sometimes get double, triple, or more of my
keystrokes repeated. I'm sure I only typed them once, what can I do?
@ -3103,6 +3177,7 @@ ied)
autorepeating so there is no big loss here, unless someone is also
working at the physical display and misses his autorepeating.
Q-61: The x11vnc -norepeat mode is in effect, but I still get repeated
@ -3126,6 +3201,7 @@ ied)
something in your desktop is automatically turning it back on you
should figure out how to disable that somehow.
Q-62: The machine where I run x11vnc has an AltGr key, but the local
machine where I run the VNC viewer does not. Is there a way I can map
a local unused key to send an AltGr? How about a Compose key as well?
@ -3140,6 +3216,7 @@ ied)
Super_R-Mode_switch,Menu-Multi_key" or use "-remap filename" to
specify remappings from a file.
Q-63: I have a Sun machine I run x11vnc on. Its Sun keyboard has just
one Alt key labelled "Alt" and two Meta keys labelled with little
diamonds. The machine where I run the VNC viewer only has Alt keys.
@ -3157,6 +3234,7 @@ ied)
cannot send Alt_L in this case, maybe -remap Super_L-Meta_L would be a
better choice if the Super_L key is typically unused.
Q-64: Can I map a keystroke to a mouse button click on the remote
@ -3202,6 +3280,7 @@ ied)
local display. Especially for hand-held devices. See also [332]this
FAQ on x11vnc scaling.
Q-66: Does x11vnc support server-side framebuffer scaling? (E.g. to
make the desktop smaller).
@ -3262,6 +3341,7 @@ ied)
scaling to a different factor (e.g. use "-scale_cursor 1" to keep the
cursor at its natural unscaled size).
Q-67: Does x11vnc work with Xinerama? (i.e. multiple monitors joined
together to form one big, single screen).
@ -3289,6 +3369,7 @@ ied)
function. (This may be due to a bug in the X server for XTEST when
Xinerama is enabled).
Q-68: Can I use x11vnc on a multi-headed display that is not Xinerama
(i.e. separate screens :0.0, :0.1, ... for each monitor)?
@ -3312,6 +3393,7 @@ ied)
this case (to limit each x11vnc to 3 shm segments), or even
[342]-noshm to use no shm segments.
Q-69: Can x11vnc show only a portion of the display? (E.g. for a
special purpose rfb application).
@ -3324,6 +3406,7 @@ ied)
the [344]-id or [345]-sid options are used. The offset is measured
from the upper left corner of the selected window.
Q-70: Does x11vnc support the XRANDR (X Resize, Rotate and Reflection)
extension? Whenever I rotate or resize the screen x11vnc just seems to
@ -3346,11 +3429,13 @@ ied)
specify "-xrandr exit" then all will be disconnected and x11vnc will
Q-71: Why is the view in my VNC viewer completely black? Or why is
everything flashing around randomly?
See the next FAQ for a possible explanation.
Q-72: I use Linux Virtual Consoles (VC's) to implement 'Fast User
Switching' between users' sessions (e.g. Betty is on Ctrl-Alt-F7,
Bobby is on Ctrl-Alt-F8, and Sid is on Ctrl-Alt-F1: they use those
@ -3378,6 +3463,7 @@ ied)
x11vnc can poll it correctly), one can use the chvt(1) command, e.g.
"chvt 7" for VC #7.
Q-73: Can I use x11vnc to view my VMWare session remotely?
Yes, since VMWare is an X application you can view it via x11vnc in
@ -3421,6 +3507,7 @@ ied)
to have a video card, (but need not have a monitor, Keyboard or
Q-74: I am using x11vnc where my local machine has "popup/hidden
taskbars" (e.g. GNOME or MacOS X) and the remote display where x11vnc
runs also has "popup/hidden taskbars" (e.g. GNOME). When I move the
@ -3449,6 +3536,7 @@ ied)
"Klipper" that do odd things with the selection, clipboard, and
Q-76: Why don't I hear the "Beeps" in my X session (e.g. when typing
tput bel in an xterm)?

@ -0,0 +1 @@
EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear slide.pl vcinject.pl x11vnc_loop

@ -0,0 +1,32 @@
In this directory you'll find a hodgepodge of wrapper scripts and
utility programs that have found some use with x11vnc.
Some are on the rough side and will need some customization for your
use. Many of them are described on the webpage:
(use your browser's Find action to find them!). Some of them also have
documentation near the top of the file.
x11vnc -accept scripts:
blockdpy.c try to lock screen if local person knocks monitor out of DPMS
dtVncPopup CDE/dtksh by Stefan Radman to accept connections, lock screen
x11vnc launch wrappers:
rx11vnc simple ssh/rsh x11vnc launcher. -S option needs work...
rx11vnc.pl perl script tries to do rx11vnc -S tunnelling better.
x11vnc -pipeinput/-rawfb utilities:
vcinject.pl perl script like LinuxVNC.c, for x11vnc viewing of linux console
slide.pl amusing example using x11vnc -rawfb for jpeg slideshow.
Misc. scripts:
shm_clear list or remove orphaned shm slots from hard x11vnc crashes.
x11vnc_loop kludge to run in bg attaching x11vnc to X login. Better to
use Xsetup mechanism.

@ -0,0 +1,352 @@
* blockdpy.c
* Copyright (c) 2004 Karl J. Runge <runge@karlrunge.com>
* All rights reserved.
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
* This tool is intended for use with x11vnc. It is a kludge to try to
* "block" access via the physical display while x11vnc is running.
* The expected application is that of a user who screen-locks his
* workstation before leaving and then later unlocks it remotely via
* x11vnc. The user is concerned people with physical access to the
* machine will be watching, etc.
* Of course if people have physical access to the machine there are
* much larger potential security problems, but the idea here is to put
* up a larger barrier than simply turning on the monitor and tapping
* the mouse (i.e. to wake up the monitor from DPMS and then observe
* the x11vnc activity).
* This program requires DPMS support in the video card and monitor,
* and the DPMS extension in the X server and the corresponding
* library with the DPMS API (libXext).
* It starts off by forcing the state to be DPMSModeOff (lowest power).
* Then it periodically (a few times a second) checks if the system is
* still in that state. If it discovers it to be in another state, it
* immediately runs, as a separate command, a screen-lock program, "xlock"
* by default. The environment variable XLOCK_CMD or -lock option can
* override this default. "xscreensaver-command" might be another choice.
* It is up to the user to make sure the screen-lock command works
* and PATH is set up correctly, etc. The command can do anything,
* it doesn't have to lock the screen. It could make the sound of a
* dog barking, for example :-)
* The option '-grab' causes the program to additionally call
* XGrabServer() to try to prevent physical mouse or keyboard input to get
* to any applications on the screen. NOTE: do NOT use, not working yet!
* Freezes everything.
* The options: -display and -auth can be used to set the DISPLAY and
* XAUTHORITY environment variables via the command line.
* The options -standby and -suspend change the desired DPMS level
* to be DPMSModeStandby and DPMSModeSuspend, respectively.
* The option '-f flagfile' indicates a flag file to watch for to cause
* the program to clean up and exit once it exists. No screen locking is
* done when the file appears: it is an 'all clear' flag. Presumably the
* x11vnc user has relocked the screen before the flagfile is created.
* See below for coupling this behavior with the -gone command.
* The option '-bg' causes the program to fork into the background and
* return 0 if everything looks ok. If there was an error up to that
* point the return value would be 1.
* Option '-v' prints more info out, useful for testing and debugging.
* These options allow this sort of x11vnc usage:
* x11vnc ... -accept "blockdpy -bg -f $HOME/.bdpy" -gone "touch $HOME/.bdpy"
* (this may also work for gone: -gone "killall blockdpy")
* In the above, once a client connects this program starts up in the
* background and monitors the DPMS level. When the client disconnects
* (he relocked the screen before doing so) the flag file is created and
* so this program exits normally. On the other hand, if the physical
* mouse or keyboard was used during the session, this program would
* have locked the screen as soon as it noticed the DPMS change.
* One could create shell scripts for -accept and -gone that do much
* more sophisticated things. This would be needed if more than one
* client connects at a time.
* It is important to remember once this program locks the screen
* it *exits*, so nothing will be watching the screen at that point.
* Don't immediately unlock the screen from in x11vnc!! Best to think
* about what might have happened, disconnect the VNC viewer, and then
* restart x11vnc (thereby having this monitoring program started again).
* To compile on Linux or Solaris:
cc -o blockdpy blockdpy.c -L /usr/X11R6/lib -L /usr/openwin/lib -lX11 -lXext
* (may also need -I /usr/.../include on older machines).
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/extensions/dpms.h>
Display *dpy = NULL;
CARD16 standby, suspend, off;
int grab = 0;
int verbose = 0;
int bg = 0;
/* for sleeping some number of millisecs */
struct timeval _mysleep;
#define msleep(x) \
_mysleep.tv_sec = ((x)*1000) / 1000000; \
_mysleep.tv_usec = ((x)*1000) % 1000000; \
select(0, NULL, NULL, NULL, &_mysleep);
/* called on signal or if DPMS changed, or other problem */
void reset(int sig) {
if (grab) {
if (verbose) {
fprintf(stderr, "calling XUngrabServer()\n");
if (verbose) {
fprintf(stderr, "resetting original DPMS values.\n");
fprintf(stderr, "blockdpy: reset sig=%d called\n", sig);
DPMSSetTimeouts(dpy, standby, suspend, off);
if (sig) {
int main(int argc, char** argv) {
int verbose = 0, bg = 0;
int i, ev, er;
char *lock_cmd = "xlock";
char *flag_file = NULL;
char estr[100], cmd[500];
struct stat sbuf;
CARD16 power;
CARD16 desired = DPMSModeOff;
BOOL state;
/* setup the lock command. it may be reset by -lock below. */
if (getenv("XLOCK_CMD")) {
lock_cmd = (char *) getenv("XLOCK_CMD");
/* process cmd line: */
for (i=1; i<argc; i++) {
if (!strcmp(argv[i], "-display")) {
sprintf(estr, "DISPLAY=%s", argv[++i]);
} else if (!strcmp(argv[i], "-auth")) {
sprintf(estr, "XAUTHORITY=%s", argv[++i]);
} else if (!strcmp(argv[i], "-lock")) {
lock_cmd = argv[++i];
} else if (!strcmp(argv[i], "-f")) {
flag_file = argv[++i];
} else if (!strcmp(argv[i], "-grab")) {
grab = 1;
} else if (!strcmp(argv[i], "-bg")) {
bg = 1;
} else if (!strcmp(argv[i], "-v")) {
verbose = 1;
} else if (!strcmp(argv[i], "-standby")) {
desired = DPMSModeStandby;
} else if (!strcmp(argv[i], "-suspend")) {
desired = DPMSModeSuspend;
} else if (!strcmp(argv[i], "-off")) {
desired = DPMSModeOff;
/* we want it to go into background to avoid blocking, so add '&'. */
strcpy(cmd, lock_cmd);
strcat(cmd, " &");
lock_cmd = cmd;
/* close any file descriptors we may have inherited (e.g. port 5900) */
for (i=3; i<=100; i++) {
/* open DISPLAY */
dpy = XOpenDisplay(NULL);
if (! dpy) {
fprintf(stderr, "XOpenDisplay failed.\n");
/* check for DPMS extension */
if (! DPMSQueryExtension(dpy, &ev, &er)) {
fprintf(stderr, "DPMSQueryExtension failed.\n");
if (! DPMSCapable(dpy)) {
fprintf(stderr, "DPMSCapable failed.\n");
/* make sure DPMS is enabled */
if (! DPMSEnable(dpy)) {
fprintf(stderr, "DPMSEnable failed.\n");
/* retrieve the timeouts for later resetting */
if (! DPMSGetTimeouts(dpy, &standby, &suspend, &off)) {
fprintf(stderr, "DPMSGetTimeouts failed.\n");
if (! standby || ! suspend || ! off) {
/* if none, set to some reasonable values */
standby = 900;
suspend = 1200;
off = 1800;
if (verbose) {
fprintf(stderr, "DPMS timeouts: %d %d %d\n", standby,
suspend, off);
/* now set them to very small values */
if (desired == DPMSModeOff) {
if (! DPMSSetTimeouts(dpy, 1, 1, 1)) {
fprintf(stderr, "DPMSSetTimeouts failed.\n");
} else if (desired == DPMSModeSuspend) {
if (! DPMSSetTimeouts(dpy, 1, 1, 0)) {
fprintf(stderr, "DPMSSetTimeouts failed.\n");
} else if (desired == DPMSModeStandby) {
if (! DPMSSetTimeouts(dpy, 1, 0, 0)) {
fprintf(stderr, "DPMSSetTimeouts failed.\n");
/* set handlers for clean up in case we terminate via signal */
signal(SIGHUP, reset);
signal(SIGINT, reset);
signal(SIGQUIT, reset);
signal(SIGABRT, reset);
signal(SIGTERM, reset);
/* force state into DPMS Off (lowest power) mode */
if (! DPMSForceLevel(dpy, desired)) {
fprintf(stderr, "DPMSForceLevel failed.\n");
/* read state */
if (! DPMSInfo(dpy, &power, &state)) {
fprintf(stderr, "DPMSInfo failed.\n");
fprintf(stderr, "power: %d state: %d\n", power, state);
/* grab display if desired. NOT WORKING */
if (grab) {
if (verbose) {
fprintf(stderr, "calling XGrabServer()\n");
/* go into background if desired. */
if (bg) {
pid_t p;
if ((p = fork()) != 0) {
if (p < 0) {
fprintf(stderr, "problem forking.\n");
} else {
/* XXX no fd closing */
/* main loop: */
while (1) {
/* reassert DPMSModeOff (desired) */
if (verbose) fprintf(stderr, "reasserting desired DPMSMode\n");
DPMSForceLevel(dpy, desired);
/* wait a bit */
/* check for flag file appearence */
if (flag_file && stat(flag_file, &sbuf) == 0) {
if (verbose) {
fprintf(stderr, "flag found: %s\n", flag_file);
/* check state and power level */
if (! DPMSInfo(dpy, &power, &state)) {
fprintf(stderr, "DPMSInfo failed.\n");
if (verbose) {
fprintf(stderr, "power: %d state: %d\n", power, state);
if (!state || power != desired) {
/* Someone (or maybe a cat) is evidently watching... */
fprintf(stderr, "DPMS CHANGE: power: %d state: %d\n",
power, state);
fprintf(stderr, "locking screen with command: \"%s\"\n", lock_cmd);

@ -0,0 +1,109 @@
# accept dialog script for x11vnc
# 2004-07-13 stefan.radman@ctbto.org
# should work in any CDE environment (Sun,HP,IBM,...)
# when called without parameters shows a CDE question dialog:
# Do you want to accept a VNC connection
# from IP address $RFB_CLIENT_IP to your desktop?
# Note:
# After 30 seconds the screen will
# be locked and the connection will be
# accepted automatically."
# [Yes} {__No__] [View/Only]
# and counts down a timer in the dialog title bar
# when the timer is down to 0, it locks the display and returns 0
# (if the screenlock was successful or if the login prompt was active)
# buttons=retcode:
# Yes = 0
# No = 1 (same as closing the dialog windows)
# View/Only = 3
# usage: x11vnc -forever -shared -accept "yes:0,no:*,view:3 dtVncPopup" -gone "dtVncPopup lock"
# security considerations: when you return to your console and unlock the display
# you can never know if enyone else is connected to your display
# timeout until accept
# dialog message
test -z "${RFB_CLIENT_IP}" && unknown="an unknown " || ip="$RFB_CLIENT_IP "
Do you want to accept a VNC connection
from ${unknown}IP address ${ip}to your desktop?
After $timeout seconds the screen will
be locked and the connection will be
accepted automatically."
# action functions
accept () {
exit 0
reject () {
exit 1
view () {
exit 3
lock () {
# lock only if dtsession active
xrdb -query | grep -c '^dtsession*' || accept
# accept only if lock succeeds
/usr/dt/bin/dtaction LockDisplay && accept || reject
# main
# actions can be called directly
test $# -gt 0 && $@
# initialize the display
XtInitialize TOPLEVEL vncPopup VncPopup "$0" "$@"
# create a message dialog containing the contents of the specified file
XmCreateQuestionDialog DIALOG $TOPLEVEL dialog \
dialogTitle:"$DTKSH_APPNAME" \
messageString:"$message" \
unmapCallback:reject \
# symbolPixmap:/usr/dt/appconfig/icons/C/DtFlag.m.pm
# change the OK button to "Yes"
XtSetValues $OK_BUTTON \
labelString:"Yes" \
# change the Cancel Button to "No"
labelString:"No" \
# change Help button to View-Only, set focus and make it the default
XtSetValues $HELP_BUTTON \
labelString:"View\nOnly" \
# make "No" the default (for unmap as well)
XtSetValues $DIALOG \
defaultButton:$CANCEL_BUTTON initialFocus:$CANCEL_BUTTON \
# create the ticker
ticker () {
test $timeout -eq 0 && lock
XtSetValues $DIALOG dialogTitle:"accepting in $timeout seconds"
XtAddTimeOut TICKER 1000 ticker
timeout=`expr $timeout - 1`
# display dialog and activate ticker
XtAddTimeOut TICKER 1000 ticker
XtManageChild $DIALOG

@ -0,0 +1,133 @@
# usage: rx11vnc [-s] <host>:<xdisplay>
# rx11vnc [-s] <host> (assumes xdisplay is 0)
# -s means use ssh instead of rsh.
# -S tries to tunnel the vnc traffic thru ssh. (experimental...)
#set -xv
# Place your x11vnc cmd + options here (must have -bg and -display
# with -display as the last one)
cmd="x11vnc -nap -q -bg -display"
# The following two settings are only used under -S (ssh tunnel)
# Unfortunately, we have to set up the ssh port redirection *before*
# x11vnc has started and selected its listening port.
# tunnel_ports is a list of ports we expect/hope to be free on both
# the local and remote machines:
tunnel_ports="5900 5901 5902 5903"
# VNC has a poor default in that if the client appears to be emanating
# from the local machine, then raw encoding is preferred. With ssh port
# redirection we appear to be coming from the localhost, but we are not.
# We pass this encoding list to the viewer to give lowest preference to
# raw encoding:
tunnel_encodings="copyrect tight zrle hextile zlib corre rre"
if [ "$USER" = "runge" ]; then
cmd="x11vnc.expt -nap -q -bg -rfbauth .vnc/passwd -display"
if [ "X$1" = "X-s" ]; then
elif [ "X$1" = "X-S" ]; then
cmd=`echo "$cmd" | sed -e 's/ / -localhost /'`
if echo "$remote" | grep ':' > /dev/null; then
host=`echo "$remote" | awk -F: '{print $1}'`
disp=`echo "$remote" | awk -F: '{print $2}'`
if [ "X$host" = "X" ]; then
echo "bad host."
exit 1
# start the remote x11vnc:
if [ $tunnel ]; then
# much more kludgy for tunnelling:
used_ports=`netstat -an | egrep '(ESTABLISHED|LISTEN) *$' \
| sed -e 's/^[ ]*//' -e 's/^tcp[ 0-9][ 0-9]*//' \
-e 's/[ ].*$//' -e 's/^.*[^0-9]//' | sort -nu`
for p in $tunnel_ports
for u in $used_ports
if [ "X$p" = "X$u" ]; then
echo "port $u is in use. skipping it"
if [ $ok ]; then
redir="$redir -L $p:localhost:$p"
# Have ssh put the command in the bg, then we look for PORT=
# in the tmp file. The sleep at the end is to give us enough
# time to connect thru the port redir, otherwise ssh will exit
# before we can connect.
$rsh -f $redir $host "$cmd $disp; echo END; sleep $time" > $tmp
while [ $i -lt $time ]
sleep 1
if grep '^PORT=' $tmp > /dev/null; then
port=`grep '^PORT=' $tmp | sed -e 's/PORT=//'`
if [ "X$port" != "X" ]; then
i=`expr $i + 1`
cat $tmp
rm -f $tmp
port=`$rsh $host "$cmd $disp" | grep '^PORT=' | sed -e 's/PORT=//'`
echo "x11vnc port is '$port'"
# now start up the viewer on this end:
if echo "$port" | grep '^[0-9][0-9]*$' > /dev/null; then
if [ $port -lt 6000 -a $port -ge 5900 ]; then
# vncviewer special cases 0-99
port=`expr $port - 5900`
if [ $tunnel ]; then
$viewer -encodings "$tunnel_encodings" "localhost:$port"
$viewer "$host:$port"
echo "bad port."
exit 1

@ -0,0 +1,199 @@
#!/bin/sh -- # A comment mentioning perl
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
# Here is the remote x11vnc command.
# Modify to your needs, required to have %DISP item that expands to X display
# and the -bg option to go into the background.
$x11vnc_cmd = "x11vnc -localhost -nap -q -bg -display %DISP";
# We will redir local ports to these remote ports hoping the remote
# x11vnc selects one of them:
@tunnel_ports = qw(5900 5901 5902 5903 5904);
# We need to specify the encoding preferences since vncviewer will
# mistakeningly prefer "raw" encoding for local connection. required to
# have %VNC_ITEM to expand to localhost:<port>
# One really needs an -encodings option otherwise the vncviewer will
# prefer 'raw' which is very slow.
$viewer_cmd = "vncviewer -encodings 'copyrect tight zrle hextile zlib corre rre' %VNC_DISP";
$sleep_time = 15;
if ($ENV{USER} eq 'runge') {
# my personal kludges:
$viewer_cmd =~ s/vncviewer/vncviewerz/; # for tight
$x11vnc_cmd .= ' -rfbauth .vnc/passwd'; # I always want rfbauth
chop($Program = `basename $0`);
$Usage = <<"END";
$Program: wrapper to tunnel vncviewer <-> x11vnc VNC traffic through a ssh
encrypted tunnel port redirection.
Usage: $Program <options> <remote-Xdisplay>
-l <user> ssh login as remote user <user>
-rfbauth <remote-auth-file> this option is passed to the remote
x11vnc command for passwd file.
Example: $Program snoopy:0
while (@ARGV) {
$_ = shift;
/^-display$/ && ($remote_xdisplay = shift, last CASE);
/^-rfbauth$/ && ($x11vnc_cmd .= ' -rfbauth ' . shift, last CASE);
/^-l$/ && ($remote_user = ' -l ' . shift, last CASE);
/^--$/ && (last LOOP); # -- means end of switches
/^-(-.*)$/ && (unshift(@ARGV, $1), last CASE);
/^(-h|-help)$/ && ((print STDOUT $Usage), exit 0, last CASE);
if ( /^-(..+)$/ ) { # split bundled switches:
local($y, $x) = ($1, '');
(unshift(@ARGV, $y), last CASE) if $y =~ /^-/;
foreach $x (reverse(split(//, $y))) { unshift(@ARGV,"-$x") };
last CASE;
/^-/ && ((print STDERR "Invalid arg: $_\n$Usage"), exit 1, last CASE);
last LOOP;
select(STDERR); $| = 1;
select(STDOUT); $| = 1;
# Determine the remote X display to connect to:
$remote_xdisplay = shift if $remote_xdisplay eq '';
if ($remote_xdisplay !~ /:/) {
$remote_xdisplay .= ':0'; # assume they mean :0 over there.
if ($remote_xdisplay =~ /:/) {
$host = $`;
$disp = ':' . $';
} else {
die "bad X display: $remote_xdisplay, must be <host>:<display>\n";
# Get list of local ports in use so we can avoid them:
# (tested on Linux and Solaris)
open(NETSTAT, "netstat -an|") || die "netstat -an: $!";
while (<NETSTAT>) {
chomp ($line = $_);
next unless $line =~ /(ESTABLISHED|LISTEN|WAIT2?)\s*$/;
$line =~ s/^\s*//;
$line =~ s/^tcp[\s\d]*//;
$line =~ s/\s.*$//;
$line =~ s/^.*\D//;
if ($line !~ /^\d+$/) {
die "bad netstat line: $line from $_";
$used_port{$line} = 1;
# Now match up free local ports with the desired remote ports
# (note that the remote ones could be in use but that won't stop
# the ssh with port redirs from succeeding)
$lport = 5900;
$cnt = 0;
foreach $rport (@tunnel_ports) {
while ($used_port{$lport}) {
die "too hard to find local ports 5900-$lport" if $cnt > 200;
$port_map{$rport} = $lport;
$redir = '';
foreach $rport (@tunnel_ports) {
$redir .= " -L $port_map{$rport}:localhost:$rport";
# Have ssh put the command in the bg, then we look for PORT= in the
# tmp file. The sleep at the end is to give us enough time to connect
# thru the port redir, otherwise ssh will exit before we can connect.
# This is the x11vnc cmd for the remote side:
$cmd = $x11vnc_cmd;
$cmd =~ s/%DISP/$disp/;
# This is the ssh cmd for the local side (this machine):
$ssh_cmd = "ssh -f $remote_user $redir $host '$cmd; echo END; sleep $sleep_time'";
$ssh_cmd =~ s/ / /g;