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

pull/1/head
runge 20 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> 2005-04-03 Karl Runge <runge@karlrunge.com>
* configure.ac: add conditional libXTrap checking * configure.ac: add conditional libXTrap checking
* x11vnc: use DEC-XTRAP on old X11R5 for grab control. * x11vnc: use DEC-XTRAP on old X11R5 for grab control.

@ -266,7 +266,7 @@ AC_FUNC_VPRINTF
AC_FUNC_FORK AC_FUNC_FORK
AC_CHECK_LIB(nsl,gethostbyname) AC_CHECK_LIB(nsl,gethostbyname)
AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(socket,socket)
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 # check, if shmget is in cygipc.a
AC_CHECK_LIB(cygipc,shmget) AC_CHECK_LIB(cygipc,shmget)
@ -295,6 +295,7 @@ AC_CONFIG_FILES([Makefile
libvncserver/Makefile libvncserver/Makefile
contrib/Makefile contrib/Makefile
x11vnc/Makefile x11vnc/Makefile
x11vnc/misc/Makefile
examples/Makefile examples/Makefile
vncterm/Makefile vncterm/Makefile
classes/Makefile classes/Makefile

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
VERSION="0.7.1pre" VERSION="0.7.2"
cd "$(dirname "$0")" 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> 2005-04-03 Karl Runge <runge@karlrunge.com>
* try DEC-XTRAP on X11R5 if XTestGrabControl is missing. * try DEC-XTRAP on X11R5 if XTestGrabControl is missing.
* -shiftcmap n, for 8bpp displays using < 256 color cells * -shiftcmap n, for 8bpp displays using < 256 color cells

@ -1,6 +1,9 @@
DEFINES = -I .. DEFINES = -I ..
LDADD = ../libvncserver/libvncserver.a @WSOCKLIB@ LDADD = ../libvncserver/libvncserver.a @WSOCKLIB@
SUBDIRS = misc
DIST_SUBDIRS = misc
man_MANS=x11vnc.1 man_MANS=x11vnc.1
EXTRA_DIST=ChangeLog README tkx11vnc $(man_MANS) 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: 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 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 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 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 environment variable (or use the [12]-auth option) to point to the
correct MIT-MAGIC-COOKIE file (e.g. /home/joe/.Xauthority). More on correct MIT-MAGIC-COOKIE file (e.g. /home/joe/.Xauthority). More on
this [13]below. this [13]below.
There will then be much chatter printed out from x11vnc, until it If you suspect an X11 permissions problem do this simple test: while
finally says something like: 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 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" specify it. Nearly always the correct value will be ":0"
For the latter error, you need to set up the X11 permissions 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 correctly.
much info. For example, you may need to set your XAUTHORITY
environment variable or use the [142]-auth option to point to the To make sure X11 permissions are the problem do this simple test:
correct cookie file (e.g. /home/joe/.Xauthority or /var/gdm/:0.Xauth), while sitting at the physical X display open a terminal window
or simply be sure you run x11vnc as the correct user (i.e. the user (gnome-terminal, xterm, etc). You should be able to start x11vnc
who owns the X session you wish to view). Running x11vnc as root is without any need for special steps or command line options in that
not enough: you need to know where the XAUTHORITY file for the desired terminal. If that works OK then you know X11 permissions are the only
X display is. Example: 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 x11vnc -display :0 -auth /var/gdm/:0.Xauth
Less safe, but to avoid figuring out where the XAUTHORITY file is, if 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 should be able to attach x11vnc to the session (from the same
machine). The person could then type "xhost -localhost" after x11vnc machine). The person could then type "xhost -localhost" after x11vnc
has connected to go back to the default permissions. Also, for some 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). documentation on the [143]-users option).
To test out your X11 permissions, set DISPLAY and possibly XAUTHORITY To test out your X11 permissions from a remote shell, set DISPLAY and
(see your shell's man page, bash(1), tcsh(1), on how to set possibly XAUTHORITY (see your shell's man page, bash(1), tcsh(1), on
environment variables) and type xdpyinfo in the same place you will be how to set environment variables) and type xdpyinfo in the same place
typing (or otherwise running) x11vnc. If information is printed out you will be typing (or otherwise running) x11vnc. If information is
about the X display (screen sizes, supported extensions, color visuals printed out about the X display (screen sizes, supported extensions,
info) that means the X11 permissions are set up properly: xdpyinfo color visuals info) that means the X11 permissions are set up
successfully connected to DISPLAY. You could also type xclock and make properly: xdpyinfo successfully connected to DISPLAY! You could also
sure no errors are reported (a clock should appear on the X display, type xclock and make sure no errors are reported (a clock should
type Ctrl-C to quit it) 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 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 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 clients must be allowed to connect to the X server to function
properly). properly).
Q-2: I can't get x11vnc and/or libvncserver to compile. Q-2: I can't get x11vnc and/or libvncserver to compile.
Make sure you have all of the required -devel packages installed. Make sure you have all of the required -devel packages installed.
@ -1092,6 +1111,7 @@ make
XFree86-devel XFree86-devel
zlib-devel zlib-devel
Q-3: I just built x11vnc successfully, but when I use it my keystrokes 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 and mouse button clicks are ignored (I am able to move the mouse
though). though).
@ -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 No XTEST extension, switching to -xwarppointer mode for
20/03/2005 22:33:09 pointer motion input. 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 Q-4: Help, I need to run x11vnc on Solaris 2.5.1 (or other old
Unix/Linux) and it doesn't compile! 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 it worked or not). If there is enough demand we will try to push clean
compilations back to earlier Solaris, Linux, etc, releases. compilations back to earlier Solaris, Linux, etc, releases.
Q-5: Where can I get a precompiled x11vnc binary for my Operating Q-5: Where can I get a precompiled x11vnc binary for my Operating
System? System?
@ -1225,6 +1247,7 @@ typedef unsigned int in_addr_t;
resulting data.tar.gz tar file. Also, rpm2cpio(1) is useful in resulting data.tar.gz tar file. Also, rpm2cpio(1) is useful in
extracting files from rpm packages. extracting files from rpm packages.
Q-6: Where can I get a VNC Viewer binary (or source code) for the Q-6: Where can I get a VNC Viewer binary (or source code) for the
Operating System I will be viewing from? 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 * [156]http://www.realvnc.com/download-free.html
* [157]http://sourceforge.net/projects/cotvnc/ * [157]http://sourceforge.net/projects/cotvnc/
Q-7: How can I see all of x11vnc's command line options and Q-7: How can I see all of x11vnc's command line options and
documentation on how to use them? 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 -help for long descriptions about each option. The output is listed
[158]here as well. [158]here as well.
Q-8: I don't like typing arcane command line options every time I 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? 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 "x11vnc ... -gui other:0" in the latter case the gui is displayed on
other:0, not the X display x11vnc is polling. other:0, not the X display x11vnc is polling.
Q-9: Can I make x11vnc more quiet and also go into the background Q-9: Can I make x11vnc more quiet and also go into the background
after starting up? after starting up?
@ -1284,6 +1310,7 @@ display :0
Note that under -bg the stderr messages will be lost unless you use Note that under -bg the stderr messages will be lost unless you use
the "[162]-o logfile" option. the "[162]-o logfile" option.
Q-10: Sometimes when a VNC viewer dies abruptly, x11vnc also dies with 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 the error message like: "Broken pipe". I'm using the -forever mode and
I want x11vnc to keep running. 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 [163]x11vnc.c file. It also has an [164]option -sigpipe exit to have
x11vnc clean up and exit upon receiving SIGPIPE. x11vnc clean up and exit upon receiving SIGPIPE.
Q-11: Are there any build-time customizations possible, e.g. change Q-11: Are there any build-time customizations possible, e.g. change
defaults, create a smaller binary, etc? 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 If other things (e.g. "-I ...") are needed in CPPFLAGS add them as
well. well.
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. Let us know if more build-time customizations would be useful.
If the system does not have the XTEST XTestGrabControl interface (some 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). 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 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 Unix to pass keyboard and mouse to the Unix monitor. Whenever I start
Win2VNC it quickly disconnects and x11vnc says: 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 non-zero in 8bpp PseudoColor on an obscure setup, and this option
corrected the problems. corrected the problems.
Q-15: Color problems: Why are the colors for some windows messed up in 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 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 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 [182]-overlay option works for Solaris machines with overlay visuals
where most of this problem occurs. where most of this problem occurs.
Q-16: How do I figure out the window id to supply to the -id windowid Q-16: How do I figure out the window id to supply to the -id windowid
option? option?
@ -1498,6 +1537,7 @@ TrueColor defdepth 24
extracts the windowid. Besides "pick" there is also "id:root" to allow extracts the windowid. Besides "pick" there is also "id:root" to allow
you to go back to root window when doing remote-control. 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 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? 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 x11vnc is known to crash under both -id and -sid, so both modes are
still experimental. Please report any reproducible bugs. still experimental. Please report any reproducible bugs.
Q-18: My X display is depth 24 at 24bpp (instead of the normal depth 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 24 at 32bpp). I'm having lots of color and visual problems with x11vnc
and/or vncviewer. What's up? and/or vncviewer. What's up?
@ -1673,6 +1714,7 @@ TrueColor defdepth 24
Alt. Alternatively, the [196]-clear_mods option and [197]-clear_keys Alt. Alternatively, the [196]-clear_mods option and [197]-clear_keys
option can be used to release pressed keys at startup and exit. 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? Q-22: Can I change settings in x11vnc without having to restart it?
Can I remote control it? Can I remote control it?
@ -1718,6 +1760,7 @@ TrueColor defdepth 24
text (i.e. not obscured like the -rfbauth VNC passwords) password text (i.e. not obscured like the -rfbauth VNC passwords) password
options. options.
Q-24: Can I have two passwords for VNC viewers, one for full access Q-24: Can I have two passwords for VNC viewers, one for full access
and the other for view-only access to the display? 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 plain text passwords from $HOME/.vnc/passwd since it is very
straight-forward to work out what to do from the VNC source code. 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 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 some users just be able to move the mouse, but not click or type
anything? anything?
@ -1758,6 +1802,7 @@ TrueColor defdepth 24
These settings can also be applied on a per-viewer basis via the 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 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 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 why doesn't it allow more than one VNC viewer to connect at the same
time? time?
@ -1776,6 +1821,7 @@ TrueColor defdepth 24
apply these security measures, they will not be done for you apply these security measures, they will not be done for you
automatically. automatically.
Q-27: Can I limit which machines incoming VNC clients can connect Q-27: Can I limit which machines incoming VNC clients can connect
from? from?
@ -1794,6 +1840,7 @@ TrueColor defdepth 24
[216](tcp_wrappers) and then use /etc/hosts.allow See hosts_access(5) [216](tcp_wrappers) and then use /etc/hosts.allow See hosts_access(5)
for complete details. for complete details.
Q-28: How do I build x11vnc/libvncserver with libwrap (tcp_wrappers) Q-28: How do I build x11vnc/libvncserver with libwrap (tcp_wrappers)
support? support?
@ -1814,6 +1861,7 @@ TrueColor defdepth 24
x11vnc with libwrap support because the /usr/sbin/tcpd reference in x11vnc with libwrap support because the /usr/sbin/tcpd reference in
/etc/inetd.conf handles the tcp_wrappers stuff. /etc/inetd.conf handles the tcp_wrappers stuff.
Q-29: Can I have x11vnc only listen on one network interface (e.g. 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 internal LAN) rather than having it listen on all network interfaces
and relying on -allow to filter unwanted connections out? 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 option [220]-localhost now implies "-listen localhost" since that is
what most people expect it to do. what most people expect it to do.
Q-30: Now that -localhost implies listening only on the loopback Q-30: Now that -localhost implies listening only on the loopback
interface, how I can occasionally allow in a non-localhost via the interface, how I can occasionally allow in a non-localhost via the
allowonce remote control command? allowonce remote control command?
@ -1847,6 +1896,7 @@ TrueColor defdepth 24
in on the listening interface. If you just toggle [225]-localhost on 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. 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 Q-31: How can I tunnel my connection to x11vnc via an encrypted SSH
channel between two Unix machines? channel between two Unix machines?
@ -1857,6 +1907,7 @@ TrueColor defdepth 24
Other secure encrypted methods exists, e.g. stunnel, IPSEC, various Other secure encrypted methods exists, e.g. stunnel, IPSEC, various
VPNs, etc. VPNs, etc.
Q-32: How can I tunnel my connection to x11vnc via an encrypted SSH Q-32: How can I tunnel my connection to x11vnc via an encrypted SSH
channel from Windows using an SSH client like Putty? 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 5500 instead of 5900 (i.e. 'Source port: 5500' and
'Destination: localhost:5500' for a Remote connection). 'Destination: localhost:5500' for a Remote connection).
Q-33: Can I prompt the user at the local X display whether the 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 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 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 variables are set as in "-accept command" (except that RFB_MODE will
be "gone"). be "gone").
Q-34: Does x11vnc support Unix usernames and passwords? Can I further 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? 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 For this to work with ssh port redirection, the ssh option
UsePrivilegeSeparation must be enabled. UsePrivilegeSeparation must be enabled.
Q-35: I start x11vnc as root because it is launched via inetd(1) or a 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 display manager like gdm(1). Can I have x11vnc later switch to a
different user? different user?
@ -2056,6 +2110,7 @@ exit 1 # reject it
+nobody" that switches to the Unix user nobody right after connections +nobody" that switches to the Unix user nobody right after connections
to the X display are established. to the X display are established.
Q-36: I use a screen-lock when I leave my workstation (e.g. Q-36: I use a screen-lock when I leave my workstation (e.g.
xscreensaver or xlock). When I remotely access my workstation desktop xscreensaver or xlock). When I remotely access my workstation desktop
via x11vnc I can unlock the desktop fine, but I am worried people will 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 obviously re-lock the screen before disconnecting!). Instructions can
be found in the source code for the utility at the above link. 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 Q-37: Can I have x11vnc automatically lock the screen when I
disconnect the VNC viewer? 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. plus any other options you desire.
Q-39: How can I use x11vnc to connect to an X login screen like xdm, 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 GNOME gdm, KDE kdm, or CDE dtlogin? (i.e. nobody is logged into an X
session yet). session yet).
@ -2279,6 +2336,7 @@ rever -bg
If the machine is a traditional Xterminal you may want to read If the machine is a traditional Xterminal you may want to read
[253]this FAQ. [253]this FAQ.
Q-40: Can I run x11vnc out of inetd(1)? How about xinetd(1)? 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 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 With the contents of /usr/local/bin/x11vnc_sh similar to the example
given above. given above.
Q-41: How do I make x11vnc work with the Java VNC viewer applet in a Q-41: How do I make x11vnc work with the Java VNC viewer applet in a
web browser? web browser?
@ -2374,6 +2433,7 @@ service x11vncservice
entirely from the viewer-side by having the jar file there and using entirely from the viewer-side by having the jar file there and using
either the java or appletviewer commands to run the program. either the java or appletviewer commands to run the program.
Q-42: Are reverse connections (i.e. the VNC server connecting to the Q-42: Are reverse connections (i.e. the VNC server connecting to the
VNC viewer) using "vncviewer -listen" and vncconnect(1) supported? 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" 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 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). 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, One can use this sort of scheme to export other virtual X sessions,
say Xnest or even Xvnc itself (useful for testing x11vnc). say Xnest or even Xvnc itself (useful for testing x11vnc).
Q-44: How can I use x11vnc on "headless" machines? Why might I want Q-44: How can I use x11vnc on "headless" machines? Why might I want
to? to?
@ -2539,6 +2601,7 @@ ied)
done over local machine sockets it should be acceptable (see an done over local machine sockets it should be acceptable (see an
[265]earlier question discussing -noshm). [265]earlier question discussing -noshm).
Q-46: How can I make x11vnc use less system resources? 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 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 [268]-onetile option will use less memory and use fewer shared memory
slots (add [269]-fs 1.0 for one less slot). slots (add [269]-fs 1.0 for one less slot).
Q-47: How can I make x11vnc use MORE system resources? 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) 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 the x11vnc [272]-id option) can be streamed over a LAN or wireless at
a reasonable frame rate. a reasonable frame rate.
Q-48: I use x11vnc over a slow link with high latency (e.g. dialup 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? 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 * Use [282]-nocursor and [283]-nocursorpos (repainting the remote
cursor position and shape takes resources and round trips) cursor position and shape takes resources and round trips)
Q-49: When I drag windows around with the mouse or scroll up and down 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 things really bog down (unless I do the drag in a single, quick
motion). Is there anything to do to improve things? 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 (try to get the viewers to use different VNC encodings, e.g. tight and
ZRLE). ZRLE).
Q-50: Does x11vnc support the X DAMAGE Xserver extension to find Q-50: Does x11vnc support the X DAMAGE Xserver extension to find
modified regions of the screen quickly and efficiently? 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 apply a patch to your VNC Viewer to extract hidden alpha channel data
under 32bpp. [296]Details can be found here. under 32bpp. [296]Details can be found here.
Q-52: When using XFIXES cursorshape mode, some of the cursors look Q-52: When using XFIXES cursorshape mode, some of the cursors look
really bad with extra black borders around the cursor and other cruft. really bad with extra black borders around the cursor and other cruft.
How can I improve their appearance? How can I improve their appearance?
@ -2780,6 +2848,7 @@ ied)
-alpharemove to brighten them by having x11vnc divide out the alpha -alpharemove to brighten them by having x11vnc divide out the alpha
value. value.
Q-53: In XFIXES mode, are there any hacks to handle cursor Q-53: In XFIXES mode, are there any hacks to handle cursor
transparency ("alpha channel") exactly? transparency ("alpha channel") exactly?
@ -2830,6 +2899,7 @@ ied)
CursorShapeUpdates) will be to draw the moving cursor into the x11vnc CursorShapeUpdates) will be to draw the moving cursor into the x11vnc
framebuffer. This can also be disabled via -nocursor. framebuffer. This can also be disabled via -nocursor.
Q-55: Can I take advantage of the TightVNC extension to the VNC Q-55: Can I take advantage of the TightVNC extension to the VNC
protocol where Cursor Positions Updates are sent back to all connected protocol where Cursor Positions Updates are sent back to all connected
clients (i.e. passive viewers can see the mouse cursor being moved 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 support the Cursor Positions Updates for the user to see the mouse
motions (the TightVNC viewers support this). As of Aug/2004 in the motions (the TightVNC viewers support this). As of Aug/2004 in the
libvncserver CVS -cursorpos is the default. See also [305]-nocursorpos 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 Q-56: Is it possible to swap the mouse buttons (e.g. left-handed
operation), or arbitrarily remap them? How about mapping button clicks operation), or arbitrarily remap them? How about mapping button clicks
to keystrokes, e.g. to partially emulate Mouse wheel scrolling? 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 [313]-debug_keyboard option prints out much info for every keystroke
and so can be useful debugging things. and so can be useful debugging things.
Q-58: When I try to type a "<" (i.e. less than) instead I get ">" Q-58: When I try to type a "<" (i.e. less than) instead I get ">"
(i.e. greater than)! Strangely, typing ">" works OK!! (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 Note that the [317]-debug_keyboard option prints out much info for
every keystroke to aid debugging keyboard problems. every keystroke to aid debugging keyboard problems.
Q-59: I'm using an "international" keyboard (e.g. German "de", or 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 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 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 when the Keysym is received from a VNC viewer, and only after that
would -add_keysyms, or anything else, come into play. would -add_keysyms, or anything else, come into play.
Q-60: When typing I sometimes get double, triple, or more of my 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? 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 autorepeating so there is no big loss here, unless someone is also
working at the physical display and misses his autorepeating. working at the physical display and misses his autorepeating.
Q-61: The x11vnc -norepeat mode is in effect, but I still get repeated Q-61: The x11vnc -norepeat mode is in effect, but I still get repeated
keystrokes!! keystrokes!!
@ -3126,6 +3201,7 @@ ied)
something in your desktop is automatically turning it back on you something in your desktop is automatically turning it back on you
should figure out how to disable that somehow. should figure out how to disable that somehow.
Q-62: The machine where I run x11vnc has an AltGr key, but the local 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 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? 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 Super_R-Mode_switch,Menu-Multi_key" or use "-remap filename" to
specify remappings from a file. specify remappings from a file.
Q-63: I have a Sun machine I run x11vnc on. Its Sun keyboard has just 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 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. 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 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. 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 Q-64: Can I map a keystroke to a mouse button click on the remote
machine? machine?
@ -3202,6 +3280,7 @@ ied)
local display. Especially for hand-held devices. See also [332]this local display. Especially for hand-held devices. See also [332]this
FAQ on x11vnc scaling. FAQ on x11vnc scaling.
Q-66: Does x11vnc support server-side framebuffer scaling? (E.g. to Q-66: Does x11vnc support server-side framebuffer scaling? (E.g. to
make the desktop smaller). make the desktop smaller).
@ -3262,6 +3341,7 @@ ied)
scaling to a different factor (e.g. use "-scale_cursor 1" to keep the scaling to a different factor (e.g. use "-scale_cursor 1" to keep the
cursor at its natural unscaled size). cursor at its natural unscaled size).
Q-67: Does x11vnc work with Xinerama? (i.e. multiple monitors joined Q-67: Does x11vnc work with Xinerama? (i.e. multiple monitors joined
together to form one big, single screen). 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 function. (This may be due to a bug in the X server for XTEST when
Xinerama is enabled). Xinerama is enabled).
Q-68: Can I use x11vnc on a multi-headed display that is not Xinerama 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)? (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 this case (to limit each x11vnc to 3 shm segments), or even
[342]-noshm to use no shm segments. [342]-noshm to use no shm segments.
Q-69: Can x11vnc show only a portion of the display? (E.g. for a Q-69: Can x11vnc show only a portion of the display? (E.g. for a
special purpose rfb application). special purpose rfb application).
@ -3324,6 +3406,7 @@ ied)
the [344]-id or [345]-sid options are used. The offset is measured the [344]-id or [345]-sid options are used. The offset is measured
from the upper left corner of the selected window. from the upper left corner of the selected window.
Q-70: Does x11vnc support the XRANDR (X Resize, Rotate and Reflection) Q-70: Does x11vnc support the XRANDR (X Resize, Rotate and Reflection)
extension? Whenever I rotate or resize the screen x11vnc just seems to extension? Whenever I rotate or resize the screen x11vnc just seems to
crash. crash.
@ -3346,11 +3429,13 @@ ied)
specify "-xrandr exit" then all will be disconnected and x11vnc will specify "-xrandr exit" then all will be disconnected and x11vnc will
terminate. terminate.
Q-71: Why is the view in my VNC viewer completely black? Or why is Q-71: Why is the view in my VNC viewer completely black? Or why is
everything flashing around randomly? everything flashing around randomly?
See the next FAQ for a possible explanation. See the next FAQ for a possible explanation.
Q-72: I use Linux Virtual Consoles (VC's) to implement 'Fast User 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, 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 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. x11vnc can poll it correctly), one can use the chvt(1) command, e.g.
"chvt 7" for VC #7. "chvt 7" for VC #7.
Q-73: Can I use x11vnc to view my VMWare session remotely? 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 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 to have a video card, (but need not have a monitor, Keyboard or
mouse)). mouse)).
Q-74: I am using x11vnc where my local machine has "popup/hidden 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 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 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 "Klipper" that do odd things with the selection, clipboard, and
cutbuffers. cutbuffers.
Q-76: Why don't I hear the "Beeps" in my X session (e.g. when typing Q-76: Why don't I hear the "Beeps" in my X session (e.g. when typing
tput bel in an xterm)? 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:
http://www.karlrunge.com/x11vnc
(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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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");
}
XUngrabServer(dpy);
}
if (verbose) {
fprintf(stderr, "resetting original DPMS values.\n");
}
fprintf(stderr, "blockdpy: reset sig=%d called\n", sig);
DPMSEnable(dpy);
DPMSSetTimeouts(dpy, standby, suspend, off);
XFlush(dpy);
if (sig) {
XCloseDisplay(dpy);
exit(0);
}
}
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]);
putenv(strdup(estr));
} else if (!strcmp(argv[i], "-auth")) {
sprintf(estr, "XAUTHORITY=%s", argv[++i]);
putenv(strdup(estr));
} else if (!strcmp(argv[i], "-lock")) {
lock_cmd = argv[++i];
} else if (!strcmp(argv[i], "-f")) {
flag_file = argv[++i];
unlink(flag_file);
} 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++) {
close(i);
}
/* open DISPLAY */
dpy = XOpenDisplay(NULL);
if (! dpy) {
fprintf(stderr, "XOpenDisplay failed.\n");
exit(1);
}
/* check for DPMS extension */
if (! DPMSQueryExtension(dpy, &ev, &er)) {
fprintf(stderr, "DPMSQueryExtension failed.\n");
exit(1);
}
if (! DPMSCapable(dpy)) {
fprintf(stderr, "DPMSCapable failed.\n");
exit(1);
}
/* make sure DPMS is enabled */
if (! DPMSEnable(dpy)) {
fprintf(stderr, "DPMSEnable failed.\n");
exit(1);
}
/* retrieve the timeouts for later resetting */
if (! DPMSGetTimeouts(dpy, &standby, &suspend, &off)) {
fprintf(stderr, "DPMSGetTimeouts failed.\n");
exit(1);
}
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");
exit(1);
}
} else if (desired == DPMSModeSuspend) {
if (! DPMSSetTimeouts(dpy, 1, 1, 0)) {
fprintf(stderr, "DPMSSetTimeouts failed.\n");
exit(1);
}
} else if (desired == DPMSModeStandby) {
if (! DPMSSetTimeouts(dpy, 1, 0, 0)) {
fprintf(stderr, "DPMSSetTimeouts failed.\n");
exit(1);
}
}
XFlush(dpy);
/* 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");
exit(1);
}
XFlush(dpy);
/* read state */
msleep(500);
if (! DPMSInfo(dpy, &power, &state)) {
fprintf(stderr, "DPMSInfo failed.\n");
exit(1);
}
fprintf(stderr, "power: %d state: %d\n", power, state);
/* grab display if desired. NOT WORKING */
if (grab) {
if (verbose) {
fprintf(stderr, "calling XGrabServer()\n");
}
XGrabServer(dpy);
}
/* go into background if desired. */
if (bg) {
pid_t p;
if ((p = fork()) != 0) {
if (p < 0) {
fprintf(stderr, "problem forking.\n");
exit(1);
} else {
/* XXX no fd closing */
exit(0);
}
}
}
/* main loop: */
while (1) {
/* reassert DPMSModeOff (desired) */
if (verbose) fprintf(stderr, "reasserting desired DPMSMode\n");
DPMSForceLevel(dpy, desired);
XFlush(dpy);
/* wait a bit */
msleep(200);
/* check for flag file appearence */
if (flag_file && stat(flag_file, &sbuf) == 0) {
if (verbose) {
fprintf(stderr, "flag found: %s\n", flag_file);
}
unlink(flag_file);
reset(0);
exit(0);
}
/* check state and power level */
if (! DPMSInfo(dpy, &power, &state)) {
fprintf(stderr, "DPMSInfo failed.\n");
reset(0);
exit(1);
}
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);
break;
}
}
reset(0);
fprintf(stderr, "locking screen with command: \"%s\"\n", lock_cmd);
system(lock_cmd);
exit(0);
}

@ -0,0 +1,109 @@
#!/usr/dt/bin/dtksh
#
# 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
timeout=30
# dialog message
test -z "${RFB_CLIENT_IP}" && unknown="an unknown " || ip="$RFB_CLIENT_IP "
message="\
Do you want to accept a VNC connection
from ${unknown}IP address ${ip}to your desktop?
Note:
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"
XmMessageBoxGetChild OK_BUTTON $DIALOG DIALOG_OK_BUTTON
XtSetValues $OK_BUTTON \
labelString:"Yes" \
activateCallback:accept
# change the Cancel Button to "No"
XmMessageBoxGetChild CANCEL_BUTTON $DIALOG DIALOG_CANCEL_BUTTON
XtSetValues $CANCEL_BUTTON \
labelString:"No" \
activateCallback:reject
# change Help button to View-Only, set focus and make it the default
XmMessageBoxGetChild HELP_BUTTON $DIALOG DIALOG_HELP_BUTTON
XtSetValues $HELP_BUTTON \
labelString:"View\nOnly" \
activateCallback:view
# 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
XtMainLoop

@ -0,0 +1,133 @@
#!/bin/sh
#
# 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"
viewer="vncviewer"
rsh=rsh
#
# 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"
viewer="vncviewerz"
fi
if [ "X$1" = "X-s" ]; then
shift
rsh=ssh
elif [ "X$1" = "X-S" ]; then
shift
rsh=ssh
tunnel=1
cmd=`echo "$cmd" | sed -e 's/ / -localhost /'`
fi
remote=$1
if echo "$remote" | grep ':' > /dev/null; then
:
else
remote="$remote:0"
fi
host=`echo "$remote" | awk -F: '{print $1}'`
disp=`echo "$remote" | awk -F: '{print $2}'`
disp=":$disp"
if [ "X$host" = "X" ]; then
echo "bad host."
exit 1
fi
# start the remote x11vnc:
if [ $tunnel ]; then
# much more kludgy for tunnelling:
tmp=/tmp/rx11vnc.$$
redir=""
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
do
ok=1
for u in $used_ports
do
if [ "X$p" = "X$u" ]; then
echo "port $u is in use. skipping it"
ok=
break
fi
done
if [ $ok ]; then
redir="$redir -L $p:localhost:$p"
fi
done
#
# 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.
#
time=15
$rsh -f $redir $host "$cmd $disp; echo END; sleep $time" > $tmp
i=0
while [ $i -lt $time ]
do
sleep 1
if grep '^PORT=' $tmp > /dev/null; then
port=`grep '^PORT=' $tmp | sed -e 's/PORT=//'`
if [ "X$port" != "X" ]; then
break
fi
fi
i=`expr $i + 1`
done
cat $tmp
rm -f $tmp
else
port=`$rsh $host "$cmd $disp" | grep '^PORT=' | sed -e 's/PORT=//'`
fi
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`
fi
if [ $tunnel ]; then
$viewer -encodings "$tunnel_encodings" "localhost:$port"
else
$viewer "$host:$port"
fi
else
echo "bad port."
exit 1
fi

@ -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>
Options:
-l <user> ssh login as remote user <user>
-rfbauth <remote-auth-file> this option is passed to the remote
x11vnc command for passwd file.
Notes:
Example: $Program snoopy:0
END
LOOP:
while (@ARGV) {
$_ = shift;
CASE: {
/^-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);
unshift(@ARGV,$_);
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;
}
close(NETSTAT);
#
# 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}) {
$lport++;
$cnt++;
die "too hard to find local ports 5900-$lport" if $cnt > 200;
}
$port_map{$rport} = $lport;
$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;
print STDERR "running ssh command:\n\n$ssh_cmd\n\n";
#
# Run ssh and redir into a tmp file (assumes ssh will use /dev/tty
# for password/passphrase dialog)
#
$tmp = "/tmp/rx.$$";
system("$ssh_cmd > $tmp");
# Now watch for the PORT=XXXX message:
$sleep = 0;
$rport = '';
print STDERR "\nWaiting for x11vnc to indicate its port ..";
while ($sleep < $sleep_time + 10) {
print STDERR ".";
sleep(1);
$sleep++;
if (`cat $tmp` =~ /PORT=(\d+)/) {
$rport = $1;
# wait 1 more second for output:
sleep(1);
if (`cat $tmp` =~ /PORT=(\d+)/) {
$rport = $1;
}
last;
}
}
print STDERR "\n";
if (! $rport) {
print STDERR `cat $tmp`;
unlink($tmp);
die "could not determine remote port.\n";
}
unlink($tmp);
# Find the remote to local mapping:
$lport = $port_map{$rport};
print STDERR "remote port is: $rport (corresponds to port $lport here)\n";
if (! $lport) {
die "could not determine local port redir.\n";
}
# Apply the special casing vncviewer does for 5900 <= port < 6000
if ($lport < 6000 && $lport >= 5900) {
$lport = $lport - 5900;
}
# Finally, run the viewer.
$cmd = $viewer_cmd;
$cmd =~ s/%VNC_DISP/localhost:$lport/;
print STDERR "running vncviewer command:\n\n$cmd\n\n";
system($cmd);

@ -0,0 +1,97 @@
#!/bin/sh
#
# shm_clear: clean out unattached (NATTACH=0) shm segments.
# See ipcs(1) and ipcrm(1). Tested on Linux and Solaris.
#
# Usage:
# shm_clear list and prompt for removal of your unattached shm segments.
# shm_clear -y assume "yes" to all the removal prompts.
# shm_clear -l only list (all of) your shm segments and exit.
#
#set -xv
if echo "$1" | grep '^-h' > /dev/null; then
# -h or -help
tail +3 $0 | head -9
exit
fi
if [ "X$USER" = "X" ]; then
USER=$LOGNAME
fi
l_arg="shmid.*owner|CREATOR|$USER"
# set up OS dependent cmdline opts, etc.
if [ `uname` = "Linux" ]; then
m_arg="-m"
r_arg="shm"
g_arg="^0x"
s_cmd="ipcs $m_arg -i %ID"
awkcut='{print $2, $6}'
elif [ `uname` = "SunOS" ]; then
m_arg="-ma"
r_arg="-m"
g_arg="^m"
s_cmd="ipcs $m_arg | egrep ' %ID |CREATOR' | grep -v IPC.status"
awkcut='{print $2, $9}'
else
echo unsupported OS: `uname`
exit 1
fi
list() {
if [ "X$1" = "X-L" ]; then
l_arg="$l_arg|."
echo "All shm segments for all:"
else
echo "All shm segments for $USER:"
fi
ipcs $m_arg | egrep "$l_arg"
echo
}
show() {
cmd=`echo "$s_cmd" | sed -e "s/%ID/$1/g"`
eval $cmd
}
remove() {
echo ipcrm $r_arg $1
ipcrm $r_arg $1
}
if [ "X$1" = "X-l" -o "X$1" = "X-L" ]; then
# list only. both attached and unattached listed.
list $1
exit 0
fi
if [ "X$1" = "X-y" ]; then
shift
yes=1 # assume "yes" to all delete questions.
else
yes=""
fi
list
ids=`ipcs $m_arg | grep "$g_arg" | grep $USER | awk "$awkcut" | grep ' 0$' | awk '{print $1}'`
if [ "X$ids" = "X" ]; then
echo "No unattached shmids for $USER."
fi
for id in $ids
do
if [ $yes ]; then
:
else
echo "-------------------------------------"
show $id
printf "\nDelete? [y]/n "
read x
if echo "$x" | grep -i n > /dev/null; then
continue
fi
fi
remove $id
done

@ -0,0 +1,112 @@
#!/bin/sh -- # A comment mentioning perl
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
#
# slide.pl: amusing example slideshow program for use with x11vnc -rawfb mode.
#
# E.g. x11vnc -rawfb map:/tmp/foo@640x480x32:ff/ff00/ff0000 -pipeinput slide.pl
#
# requires: jpegtopnm(1), (maybe LSB too).
#
@jpegs = qw(
dr_fun_new.jpg canon.jpg go_microsoft.jpg jonathan2.jpg
michelle1.jpg novm.jpg photo-008.jpg presrange.jpg
);
# Or:
# @jpegs = @ARGV;
# @jpegs = <*.jpg>;
# this is x11vnc's -rawfb value:
if ($ENV{X11VNC_RAWFB_STR} =~ m,:(.*)@(\d+)x(\d+)x(\d+),) {
$fb = $1; # filename
$W = $2; # width
$H = $3; # height
} else {
die "No usable X11VNC_RAWFB_STR\n";
}
open(FB, ">$fb") || die "$!";
# make a solid background:
$ones = "\377" x ($W * 4);
$grey = "\340" x ($W * 4);
for ($y = 0; $y < $H; $y++) {
print FB $grey;
}
# this is rather slow with many jpegs... oh well.
foreach $pic (@jpegs) {
print STDERR "loading '$pic' please wait ...\n";
open(JPEG, "jpegtopnm '$pic' 2>/dev/null|") || die "$!";
while (<JPEG>) {
next if /^P\d/;
if (/^(\d+)\s+(\d+)\s*$/) {
$Jpeg{$pic}{w} = $1;
$Jpeg{$pic}{h} = $2;
}
last if /^255$/;
}
$data = '';
while (<JPEG>) {
$data .= $_;
}
close(JPEG);
# need to put in a 4th 0 byte after RGB for 32bpp. 24bpp doesn't work.
# (MSB might be other way around).
$new = '';
for ($l = 0; $l < int(length($data)/3); $l++) {
$new .= substr($data, $l * 3, 3) . "\0";
}
$Jpeg{$pic}{data} = $new;
$data = ''; $new = '';
if ($pic eq $jpegs[0]) {
showpic(0);
}
}
$N = scalar(@jpegs);
print STDERR "\nFinished loading $N images. Click Button or Spacebar for next.\n";
$I = 0;
while (<>) {
# read the next user input event, watch for button press or spacebar:
last if /^Keysym.* [qQ] /;
next unless /^(Pointer.*ButtonPress|Keysym.*space.*KeyPress)/;
$I = ($I + 1) % $N;
showpic($I);
}
sub showpic {
my($i) = @_;
my $pic = $jpegs[$i];
my $h = $Jpeg{$pic}{h};
my $w = $Jpeg{$pic}{w};
my $dy = int(($H - $h)/2);
my $dx = int(($W - $w)/2);
print STDERR "showing pic $i: $pic\t$w x $h +$dy+$dx\n";
# clear screen:
seek(FB, 0, 0);
for ($y = 0; $y < $H; $y++) {
print FB $ones;
}
# insert new picture:
for ($y = 0; $y < $h; $y++) {
seek(FB, (($y + $dy) * $W + $dx) * 4, 0);
$line = substr($Jpeg{$pic}{data}, $y * $w * 4, $w * 4);
print FB $line;
}
}
close(FB);
#unlink($fb); # this (probably) won't kill x11vnc
print STDERR "$0 done.\n";

@ -0,0 +1,113 @@
#!/bin/sh -- # A comment mentioning perl
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
#
# vcinject.pl: simple hack to inject keystrokes into Linux VC tty.
# See LinuxVNC.c for a more careful treatment using C and public API.
#
# Usage: vcinject.pl <N> (or /dev/ttyN)
#
# This is an example x11vnc -pipeinput program E.g.:
#
# x11vnc -rawfb map:/dev/fb0@1024x768x16 -pipeinput "vcinject.pl /dev/tty3"
#
# (see fbset(8) for obtaining fb info).
#
# It reads lines like this from STDIN:
#
# Keysym <id> <down> <n> <Keysym> ...
#
# <id> is ignored, it uses the rest to deduce the keystrokes to send
# to the console.
#
$tty = shift;
$tty = "/dev/tty$tty" if $tty =~ /^\d+$/;
warn "strange tty device: $tty\n" if $tty !~ m,^/dev/tty\d+$,;
open(TTY, ">$tty") || die "open $tty: $!\n";
$fd = fileno(TTY);
$linux_ioctl_syscall = 54; # common knowledge, eh? :-)
$TIOCSTI = 0x5412;
%Map = qw(
Escape 27
Tab 9
Return 13
BackSpace 8
Home 1
End 5
Up 16
Down 14
Right 6
Left 2
Next 6
Prior 2
);
# the latter few above seem to be vi specials. (since they are normally
# escape sequences, e.g. ESC [ 5 ~)
sub lookup {
my($down, $key, $name) = @_;
my $n = -1;
$name =~ s/^KP_//;
# algorithm borrowed from LinuxVNC.c:
if (! $down) {
if ($name =~ /^Control/) {
$control--;
}
return $n;
}
if ($name =~ /^Control/) {
$control++;
} else {
if (exists($Map{$name})) {
$n = $Map{$name};
}
if ($control && $name =~ /^[A-z]$/) {
$n = ord($name);
# shift down to the Control zone:
if ($name =~ /[a-z]/) {
$n -= (ord("a") - 1);
} else {
$n -= (ord("A") - 1);
}
}
if ($n < 0 && $key < 256) {
$n = $key;
}
}
return $n;
}
$control = 0;
$debug = 0;
while (<>) {
chomp;
if (/^\w+$/) {
# for debugging, you type the keysym in manually.
$_ = "Keysym 1 0 999 $_ None";
}
next unless /^Keysym/;
my ($j, $id, $down, $k, $keysym, $rest) = split(' ', $_);
$n = lookup($down, $k, $keysym);
if ($n < 0 || $n > 255) {
print STDERR "skip: '$keysym' -> $n\n" if $down && $debug;
next;
}
$n_p = pack("c", $n);
$ret = syscall($linux_ioctl_syscall, $fd, $TIOCSTI, $n_p);
print STDERR "ctrl=$control $keysym/$k syscall(" .
"$linux_ioctl_syscall, $fd, $TIOCSTI, $n) = $ret\n" if $debug;
}

@ -0,0 +1,89 @@
#!/bin/sh
#
# x11vnc_loop:
#
# Example startup script for connecting x11vnc to an X display
# at system boot up and having it reconnect when the X server restarts.
#
# Run, in rc.local say, via, e.g.:
#
# /path/to/x11vnc_loop 1>> /var/tmp/x11vnc_loop.log 2>&1 &
#
# call with argument "once" or a number to limit the number of loops.
#
##########################################################################
# The following needs to be customized:
x11vnc_cmd=x11vnc # or use full path (or set PATH).
pwfile=/path/to/vnc/passwd # always use a password
display=:0 # display of interest
restart_sleep=5 # pause between X server restarts.
# modify cmdline args if desired:
x11vnc_args="-display $display -rfbauth $pwfile -forever -nap"
# you may need to customize the "grep", etc, below in get_xauthority_file()
##########################################################################
if [ "X$1" != "X" ]; then
max=$1
shift
fi
get_xauthority_file() {
#
# We need to find the MIT-COOKIE file... this not portable at all,
# depends on OS, distro, desktop, phase of moon, etc...
#
# If the cookie file was fixed and you knew it, you could just
# return it here e.g.:
#
## echo "/var/gdm/:0.Xauth"; return
#
# or, if you knew the directory, you could look for the youngest
# file there and return it e.g.:
#
## echo `ls -t /var/lib/xdm/authdir/authfiles/* | head -1`; return
# this hack tries to grep it out of ps output...
xauth=""
for i in 1 2 3
do
# very linux specific, and you likely need to tweak..
patt="X11R6.*/X.*-auth"
xauth=`ps wwwaux | grep "$patt" \
| egrep -v 'grep|Xprt' | head -1 \
| sed -e 's/^.*-auth//' | awk '{print $1}'`
if [ "X$xauth" != "X" ]; then
break
fi
sleep 2 # wait a bit in case X server is restarting slowly.
done
echo $xauth
}
try=1
while [ 1 ]
do
echo "`date` $0 try number: $try"; try=`expr $try + 1`
auth=`get_xauthority_file`
if [ ! -r "$auth" ]; then
echo "`date` bad auth file: \"$auth\""
else
cmd="$x11vnc_cmd $x11vnc_args"
sleep 1
echo "`date` running: $cmd -auth $auth"
# run x11vnc:
$cmd -auth $auth
if [ "X$max" = "Xonce" ]; then
exit $?
fi
fi
if echo "$max" | grep '[0-9]' > /dev/null; then
if [ $try -gt $max ]; then
exit
fi
fi
sleep $restart_sleep
done

@ -112,17 +112,17 @@ Screen
overlay overlay
overlay_nocursor overlay_nocursor
-- --
=D solid
solid_color:
visual: visual:
flashcmap flashcmap
shiftcmap: shiftcmap:
notruecolor notruecolor
-- --
clip:
=P blackout: =P blackout:
xinerama xinerama
-- clip:
=D solid rawfb:
solid_color:
-- --
= xrandr = xrandr
=-C:resize,newfbsize,exit xrandr_mode: =-C:resize,newfbsize,exit xrandr_mode:
@ -170,6 +170,8 @@ Misc
noprimary noprimary
nolookup nolookup
-- --
xtrap
--
bg bg
=-C:ignore,exit sigpipe: =-C:ignore,exit sigpipe:
=0 inetd =0 inetd
@ -2883,7 +2885,7 @@ proc start_x11vnc {} {
proc run_remote_cmd {opts} { proc run_remote_cmd {opts} {
global menu_var x11vnc_prog x11vnc_cmdline x11vnc_xdisplay global menu_var x11vnc_prog x11vnc_cmdline x11vnc_xdisplay
global x11vnc_auth_file global x11vnc_auth_file x11vnc_connect_file
set debug [in_debug_mode] set debug [in_debug_mode]
@ -2902,13 +2904,18 @@ proc run_remote_cmd {opts} {
lappend cmd $x11vnc_prog; lappend cmd $x11vnc_prog;
if {$x11vnc_xdisplay != ""} { if {$x11vnc_connect_file != ""} {
lappend cmd "-display" lappend cmd "-connect"
lappend cmd $x11vnc_xdisplay lappend cmd $x11vnc_connect_file
} } else {
if {$x11vnc_auth_file != ""} { if {$x11vnc_xdisplay != ""} {
lappend cmd "-auth" lappend cmd "-display"
lappend cmd $x11vnc_auth_file lappend cmd $x11vnc_xdisplay
}
if {$x11vnc_auth_file != ""} {
lappend cmd "-auth"
lappend cmd $x11vnc_auth_file
}
} }
lappend cmd "-sync" lappend cmd "-sync"
foreach word $opts { foreach word $opts {
@ -2998,7 +3005,7 @@ proc try_connect {} {
# main: # main:
global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect; global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;
global x11vnc_auth_file beginner_mode simple_gui_created global x11vnc_auth_file x11vnc_connect_file beginner_mode simple_gui_created
global helpall helptext helpremote helplabel hostname; global helpall helptext helpremote helplabel hostname;
global all_settings reply_xdisplay always_update global all_settings reply_xdisplay always_update
global max_text_height max_text_width global max_text_height max_text_width
@ -3069,6 +3076,12 @@ if {[info exists env(X11VNC_CONNECT)]} {
set x11vnc_connect 0; set x11vnc_connect 0;
} }
if {[info exists env(X11VNC_CONNECT_FILE)]} {
set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);
} else {
set x11vnc_connect_file "";
}
if {[info exists env(X11VNC_XDISPLAY)]} { if {[info exists env(X11VNC_XDISPLAY)]} {
set x11vnc_xdisplay $env(X11VNC_XDISPLAY); set x11vnc_xdisplay $env(X11VNC_XDISPLAY);
set x11vnc_connect 1 set x11vnc_connect 1

@ -118,17 +118,17 @@
" overlay\n" " overlay\n"
" overlay_nocursor\n" " overlay_nocursor\n"
" --\n" " --\n"
" =D solid\n"
" solid_color:\n"
" visual:\n" " visual:\n"
" flashcmap\n" " flashcmap\n"
" shiftcmap:\n" " shiftcmap:\n"
" notruecolor\n" " notruecolor\n"
" --\n" " --\n"
" clip:\n"
" =P blackout:\n" " =P blackout:\n"
" xinerama\n" " xinerama\n"
" --\n" " clip:\n"
" =D solid\n" " rawfb:\n"
" solid_color:\n"
" --\n" " --\n"
" = xrandr\n" " = xrandr\n"
" =-C:resize,newfbsize,exit xrandr_mode:\n" " =-C:resize,newfbsize,exit xrandr_mode:\n"
@ -176,6 +176,8 @@
" noprimary\n" " noprimary\n"
" nolookup\n" " nolookup\n"
" --\n" " --\n"
" xtrap\n"
" --\n"
" bg\n" " bg\n"
" =-C:ignore,exit sigpipe:\n" " =-C:ignore,exit sigpipe:\n"
" =0 inetd\n" " =0 inetd\n"
@ -2889,7 +2891,7 @@
"\n" "\n"
"proc run_remote_cmd {opts} {\n" "proc run_remote_cmd {opts} {\n"
" global menu_var x11vnc_prog x11vnc_cmdline x11vnc_xdisplay\n" " global menu_var x11vnc_prog x11vnc_cmdline x11vnc_xdisplay\n"
" global x11vnc_auth_file\n" " global x11vnc_auth_file x11vnc_connect_file\n"
"\n" "\n"
" set debug [in_debug_mode]\n" " set debug [in_debug_mode]\n"
"\n" "\n"
@ -2908,13 +2910,18 @@
"\n" "\n"
" lappend cmd $x11vnc_prog;\n" " lappend cmd $x11vnc_prog;\n"
"\n" "\n"
" if {$x11vnc_xdisplay != \"\"} {\n" " if {$x11vnc_connect_file != \"\"} {\n"
" lappend cmd \"-display\"\n" " lappend cmd \"-connect\"\n"
" lappend cmd $x11vnc_xdisplay\n" " lappend cmd $x11vnc_connect_file\n"
" }\n" " } else {\n"
" if {$x11vnc_auth_file != \"\"} {\n" " if {$x11vnc_xdisplay != \"\"} {\n"
" lappend cmd \"-auth\"\n" " lappend cmd \"-display\"\n"
" lappend cmd $x11vnc_auth_file\n" " lappend cmd $x11vnc_xdisplay\n"
" }\n"
" if {$x11vnc_auth_file != \"\"} {\n"
" lappend cmd \"-auth\"\n"
" lappend cmd $x11vnc_auth_file\n"
" }\n"
" }\n" " }\n"
" lappend cmd \"-sync\"\n" " lappend cmd \"-sync\"\n"
" foreach word $opts {\n" " foreach word $opts {\n"
@ -3004,7 +3011,7 @@
"# main:\n" "# main:\n"
"\n" "\n"
"global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;\n" "global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;\n"
"global x11vnc_auth_file beginner_mode simple_gui_created\n" "global x11vnc_auth_file x11vnc_connect_file beginner_mode simple_gui_created\n"
"global helpall helptext helpremote helplabel hostname;\n" "global helpall helptext helpremote helplabel hostname;\n"
"global all_settings reply_xdisplay always_update\n" "global all_settings reply_xdisplay always_update\n"
"global max_text_height max_text_width\n" "global max_text_height max_text_width\n"
@ -3075,6 +3082,12 @@
" set x11vnc_connect 0;\n" " set x11vnc_connect 0;\n"
"}\n" "}\n"
"\n" "\n"
"if {[info exists env(X11VNC_CONNECT_FILE)]} {\n"
" set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);\n"
"} else {\n"
" set x11vnc_connect_file \"\";\n"
"}\n"
"\n"
"if {[info exists env(X11VNC_XDISPLAY)]} {\n" "if {[info exists env(X11VNC_XDISPLAY)]} {\n"
" set x11vnc_xdisplay $env(X11VNC_XDISPLAY);\n" " set x11vnc_xdisplay $env(X11VNC_XDISPLAY);\n"
" set x11vnc_connect 1\n" " set x11vnc_connect 1\n"

@ -2,7 +2,7 @@
.TH X11VNC "1" "April 2005" "x11vnc " "User Commands" .TH X11VNC "1" "April 2005" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.7.2pre, lastmod: 2005-04-03 version: 0.7.2pre, lastmod: 2005-04-10
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
@ -180,16 +180,18 @@ is taken as a floating point number, alternatively
the notation "m/n" may be used to denote fractions the notation "m/n" may be used to denote fractions
exactly, e.g. \fB-scale\fR 2/3 exactly, e.g. \fB-scale\fR 2/3
.IP .IP
Scaling Options: can be added after \fIfraction\fR via Scaling Options: can be added after \fIfraction\fR
":", to supply multiple ":" options use commas. via ":", to supply multiple ":" options use
If you just want a quick, rough scaling without commas. If you just want a quick, rough scaling
blending, append ":nb" to \fIfraction\fR (e.g. \fB-scale\fR without blending, append ":nb" to \fIfraction\fR
1/3:nb). For compatibility with vncviewers the scaled (e.g. \fB-scale\fR 1/3:nb). No blending is the default
width is adjusted to be a multiple of 4: to disable for 8bpp indexed color, to force blending for this
this use ":n4". More esoteric options: ":in" use case use ":fb". For compatibility with vncviewers
interpolation scheme even when shrinking, ":pad", the scaled width is adjusted to be a multiple of 4:
pad scaled width and height to be multiples of scaling to disable this use ":n4". More esoteric options:
denominator (e.g. 3 for 2/3). ":in" use interpolation scheme even when shrinking,
":pad", pad scaled width and height to be multiples
of scaling denominator (e.g. 3 for 2/3).
.PP .PP
\fB-scale_cursor\fR \fIfrac\fR \fB-scale_cursor\fR \fIfrac\fR
.IP .IP
@ -564,6 +566,15 @@ areas to black out (if your system has libXinerama).
In general on XINERAMA displays you may need to use the In general on XINERAMA displays you may need to use the
\fB-xwarppointer\fR option if the mouse pointer misbehaves. \fB-xwarppointer\fR option if the mouse pointer misbehaves.
.PP .PP
\fB-xtrap\fR
.IP
Use the DEC-XTRAP extension for keystroke and mouse
input insertion. For use on legacy systems, e.g. X11R5,
running an incomplete or missing XTEST extension.
By default DEC-XTRAP will be used if XTEST server grab
control is missing, use \fB-xtrap\fR to do the keystroke and
mouse insertion via DEC-XTRAP as well.
.PP
\fB-xrandr\fR \fI[mode]\fR \fB-xrandr\fR \fI[mode]\fR
.IP .IP
If the display supports the XRANDR (X Resize, Rotate If the display supports the XRANDR (X Resize, Rotate
@ -613,6 +624,12 @@ Write stderr messages to file \fIlogfile\fR instead of
to the terminal. Same as "\fB-logfile\fR \fIfile\fR". To append to the terminal. Same as "\fB-logfile\fR \fIfile\fR". To append
to the file use "\fB-oa\fR \fIfile\fR" or "\fB-logappend\fR \fIfile\fR". to the file use "\fB-oa\fR \fIfile\fR" or "\fB-logappend\fR \fIfile\fR".
.PP .PP
\fB-flag\fR \fIfile\fR
.IP
Write the "PORT=NNNN" (e.g. PORT=5900) string to
\fIfile\fR in addition to stdout. This option could be
useful by wrapper script to detect when x11vnc is ready.
.PP
\fB-rc\fR \fIfilename\fR \fB-rc\fR \fIfilename\fR
.IP .IP
Use \fIfilename\fR instead of $HOME/.x11vncrc for rc file. Use \fIfilename\fR instead of $HOME/.x11vncrc for rc file.
@ -1142,6 +1159,64 @@ this mode is very wasteful of memory I/O resources
It may be of use in video capture-like applications, It may be of use in video capture-like applications,
or where window tearing is a problem. or where window tearing is a problem.
.PP .PP
\fB-rawfb\fR \fIstring\fR
.IP
Experimental option, instead of polling X, poll the
memory object specified in \fIstring\fR. For shared
memory segments it is of the form: "shm:N@WxHxB"
which specifies a shmid N and framebuffer width, height,
and bits per pixel. To memory map
.IR mmap (2)
a file use:
"map:/path/to/a/file@WxHxB". If there is trouble
with mmap, use "file:/..." for slower
.IR lseek (2)
based
reading.
.IP
Optional suffixes are ":R/G/B" and "+O" to specify
red, green, and blue masks and an offset into the
memory object. If the masks are not provided x11vnc
guesses them based on the bpp.
.IP
Examples:
\fB-rawfb\fR shm:210337933@800x600x32:ff/ff00/ff0000
\fB-rawfb\fR map:/dev/fb0@1024x768x32
\fB-rawfb\fR map:/tmp/Xvfb_screen0@640x480x8+3232
\fB-rawfb\fR file:/tmp/my.pnm@250x200x24+37
.IP
(see
.IR ipcs (1)
and
.IR fbset (1)
for the first two examples)
.IP
All user input is discarded. Most of the X11 (screen,
keyboard, mouse) options do not make sense and many
will cause this mode to crash, so please think twice
before setting/changing them. If you don't want x11vnc
to close the DISPLAY in rawfb mode, then capitalize
the prefix, SHM:, MAP: etc. Keeping the display open
enables defautl remote control channel.
.PP
\fB-pipeinput\fR \fIcmd\fR
.IP
Another experimental option: it lets you supply an
extern command in \fIcmd\fR that x11vnc will pipe all of
the user input events to in a simple format. By default
x11vnc will not process any of the user input events.
If you prefix \fIcmd\fR with "tee:" it will both send
them to the pipe command and process them. For a
description of the format run "\fB-pipeinput\fR \fItee:cat\fR".
Another prefix is "reopen" which means to reopen pipe
if it exits. Separate multiple prefixes with commas.
.IP
In combination with \fB-rawfb\fR one might be able to
do amusing things (e.g. control non-X devices).
To facilitate this, if \fB-rawfb\fR is in effect then the
value is stored in X11VNC_RAWFB_STR for the pipe command
to use if it wants. Do 'env | grep X11VNC' for more.
.PP
\fB-gui\fR \fI[gui-opts]\fR \fB-gui\fR \fI[gui-opts]\fR
.IP .IP
Start up a simple tcl/tk gui based on the the remote Start up a simple tcl/tk gui based on the the remote
@ -1373,6 +1448,10 @@ xinerama enable \fB-xinerama\fR mode. (if applicable)
.IP .IP
noxinerama disable \fB-xinerama\fR mode. noxinerama disable \fB-xinerama\fR mode.
.IP .IP
xtrap enable \fB-xtrap\fR input mode.
.IP
noxtrap disable \fB-xtrap\fR input mode.
.IP
xrandr enable \fB-xrandr\fR mode. (if applicable) xrandr enable \fB-xrandr\fR mode. (if applicable)
.IP .IP
noxrandr disable \fB-xrandr\fR mode. noxrandr disable \fB-xrandr\fR mode.
@ -1525,6 +1604,8 @@ snapfb enable \fB-snapfb\fR mode.
.IP .IP
nosnapfb disable \fB-snapfb\fR mode. nosnapfb disable \fB-snapfb\fR mode.
.IP .IP
rawfb:str set \fB-rawfb\fR mode to "str".
.IP
progressive:n set libvncserver \fB-progressive\fR slice progressive:n set libvncserver \fB-progressive\fR slice
height parameter to n. height parameter to n.
.IP .IP
@ -1622,39 +1703,39 @@ scale_cursor viewonly noviewonly shared noshared
forever noforever once timeout deny lock nodeny unlock forever noforever once timeout deny lock nodeny unlock
connect allowonce allow localhost nolocalhost listen connect allowonce allow localhost nolocalhost listen
lookup nolookup accept gone shm noshm flipbyteorder lookup nolookup accept gone shm noshm flipbyteorder
noflipbyteorder onetile noonetile solid_color solid noflipbyteorder onetile noonetile solid_color
nosolid blackout xinerama noxinerama xrandr noxrandr solid nosolid blackout xinerama noxinerama xtrap
xrandr_mode padgeom quiet q noquiet modtweak nomodtweak noxtrap xrandr noxrandr xrandr_mode padgeom quiet q
xkb noxkb skip_keycodes add_keysyms noadd_keysyms noquiet modtweak nomodtweak xkb noxkb skip_keycodes
clear_mods noclear_mods clear_keys noclear_keys add_keysyms noadd_keysyms clear_mods noclear_mods
remap repeat norepeat fb nofb bell nobell sel nosel clear_keys noclear_keys remap repeat norepeat fb nofb
primary noprimary cursorshape nocursorshape cursorpos bell nobell sel nosel primary noprimary cursorshape
nocursorpos cursor show_cursor noshow_cursor nocursor nocursorshape cursorpos nocursorpos cursor show_cursor
arrow xfixes noxfixes xdamage noxdamage xd_area noshow_cursor nocursor arrow xfixes noxfixes xdamage
xd_mem alphacut alphafrac alpharemove noalpharemove noxdamage xd_area xd_mem alphacut alphafrac alpharemove
alphablend noalphablend xwarp xwarppointer noxwarp noalpharemove alphablend noalphablend xwarp xwarppointer
noxwarppointer buttonmap dragging nodragging noxwarp noxwarppointer buttonmap dragging nodragging
pointer_mode pm input_skip input client_input speeds pointer_mode pm input_skip input client_input speeds
debug_pointer dp nodebug_pointer nodp debug_keyboard dk debug_pointer dp nodebug_pointer nodp debug_keyboard dk
nodebug_keyboard nodk deferupdate defer wait rfbwait nodebug_keyboard nodk deferupdate defer wait rfbwait
nap nonap sb screen_blank fs gaps grow fuzz snapfb nap nonap sb screen_blank fs gaps grow fuzz snapfb
nosnapfb progressive rfbport http nohttp httpport nosnapfb rawfb progressive rfbport http nohttp httpport
httpdir enablehttpproxy noenablehttpproxy alwaysshared httpdir enablehttpproxy noenablehttpproxy alwaysshared
noalwaysshared nevershared noalwaysshared dontdisconnect noalwaysshared nevershared noalwaysshared dontdisconnect
nodontdisconnect desktop noremote nodontdisconnect desktop noremote
.IP .IP
aro= display vncdisplay desktopname http_url auth aro= display vncdisplay desktopname http_url auth
users rootshift clipshift scale_str scaled_x scaled_y users rootshift clipshift scale_str scaled_x scaled_y
scale_numer scale_denom scale_fac scaling_noblend scale_numer scale_denom scale_fac scaling_blend
scaling_nomult4 scaling_pad scaling_interpolate inetd scaling_nomult4 scaling_pad scaling_interpolate
safer unsafe passwdfile using_shm logfile o rc norc inetd safer unsafe passwdfile using_shm logfile o
h help V version lastmod bg sigpipe threads clients flag rc norc h help V version lastmod bg sigpipe
client_count pid ext_xtest ext_xtrap ext_xkb ext_xshm threads clients client_count pid ext_xtest ext_xtrap
ext_xinerama ext_overlay ext_xfixes ext_xdamage ext_xkb ext_xshm ext_xinerama ext_overlay ext_xfixes
ext_xrandr rootwin num_buttons button_mask mouse_x ext_xdamage ext_xrandr rootwin num_buttons button_mask
mouse_y bpp depth indexed_color dpy_x dpy_y wdpy_x mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y
wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y rfbauth wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y
passwd rfbauth passwd
.PP .PP
\fB-sync\fR \fB-sync\fR
.IP .IP

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save