Commit baee5e2b authored by runge's avatar runge

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

parent ac01f36c
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_FUNC_FORK
AC_CHECK_LIB(nsl,gethostbyname)
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
AC_CHECK_LIB(cygipc,shmget)
......@@ -295,6 +295,7 @@ AC_CONFIG_FILES([Makefile
libvncserver/Makefile
contrib/Makefile
x11vnc/Makefile
x11vnc/misc/Makefile
examples/Makefile
vncterm/Makefile
classes/Makefile
......
#!/bin/bash
VERSION="0.7.1pre"
VERSION="0.7.2"
cd "$(dirname "$0")"
......
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
......
DEFINES = -I ..
LDADD = ../libvncserver/libvncserver.a @WSOCKLIB@
SUBDIRS = misc
DIST_SUBDIRS = misc
man_MANS=x11vnc.1
EXTRA_DIST=ChangeLog README tkx11vnc $(man_MANS)
......
This diff is collapsed.
EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear slide.pl vcinject.pl x11vnc_loop
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.
This diff is collapsed.
#!/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
#!/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
#!/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);
#!/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
#!/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";
#!/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;
}
#!/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_nocursor
--
=D solid
solid_color:
visual:
flashcmap
shiftcmap:
notruecolor
--
clip:
=P blackout:
xinerama
--
=D solid
solid_color:
clip:
rawfb:
--
= xrandr
=-C:resize,newfbsize,exit xrandr_mode:
......@@ -170,6 +170,8 @@ Misc
noprimary
nolookup
--
xtrap
--
bg
=-C:ignore,exit sigpipe:
=0 inetd
......@@ -2883,7 +2885,7 @@ proc start_x11vnc {} {
proc run_remote_cmd {opts} {
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]
......@@ -2902,6 +2904,10 @@ proc run_remote_cmd {opts} {
lappend cmd $x11vnc_prog;
if {$x11vnc_connect_file != ""} {
lappend cmd "-connect"
lappend cmd $x11vnc_connect_file
} else {
if {$x11vnc_xdisplay != ""} {
lappend cmd "-display"
lappend cmd $x11vnc_xdisplay
......@@ -2910,6 +2916,7 @@ proc run_remote_cmd {opts} {
lappend cmd "-auth"
lappend cmd $x11vnc_auth_file
}
}
lappend cmd "-sync"
foreach word $opts {
lappend cmd $word
......@@ -2998,7 +3005,7 @@ proc try_connect {} {
# main:
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 all_settings reply_xdisplay always_update
global max_text_height max_text_width
......@@ -3069,6 +3076,12 @@ if {[info exists env(X11VNC_CONNECT)]} {
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)]} {
set x11vnc_xdisplay $env(X11VNC_XDISPLAY);
set x11vnc_connect 1
......
......@@ -118,17 +118,17 @@
" overlay\n"
" overlay_nocursor\n"
" --\n"
" =D solid\n"
" solid_color:\n"
" visual:\n"
" flashcmap\n"
" shiftcmap:\n"
" notruecolor\n"
" --\n"
" clip:\n"
" =P blackout:\n"
" xinerama\n"
" --\n"
" =D solid\n"
" solid_color:\n"
" clip:\n"
" rawfb:\n"
" --\n"
" = xrandr\n"
" =-C:resize,newfbsize,exit xrandr_mode:\n"
......@@ -176,6 +176,8 @@
" noprimary\n"
" nolookup\n"
" --\n"
" xtrap\n"
" --\n"
" bg\n"
" =-C:ignore,exit sigpipe:\n"
" =0 inetd\n"
......@@ -2889,7 +2891,7 @@
"\n"
"proc run_remote_cmd {opts} {\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"
" set debug [in_debug_mode]\n"
"\n"
......@@ -2908,6 +2910,10 @@
"\n"
" lappend cmd $x11vnc_prog;\n"
"\n"
" if {$x11vnc_connect_file != \"\"} {\n"
" lappend cmd \"-connect\"\n"
" lappend cmd $x11vnc_connect_file\n"
" } else {\n"
" if {$x11vnc_xdisplay != \"\"} {\n"
" lappend cmd \"-display\"\n"
" lappend cmd $x11vnc_xdisplay\n"
......@@ -2916,6 +2922,7 @@
" lappend cmd \"-auth\"\n"
" lappend cmd $x11vnc_auth_file\n"
" }\n"
" }\n"
" lappend cmd \"-sync\"\n"
" foreach word $opts {\n"
" lappend cmd $word\n"
......@@ -3004,7 +3011,7 @@
"# main:\n"
"\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 all_settings reply_xdisplay always_update\n"
"global max_text_height max_text_width\n"
......@@ -3075,6 +3082,12 @@
" set x11vnc_connect 0;\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"
" set x11vnc_xdisplay $env(X11VNC_XDISPLAY);\n"
" set x11vnc_connect 1\n"
......
......@@ -2,7 +2,7 @@
.TH X11VNC "1" "April 2005" "x11vnc " "User Commands"
.SH NAME
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
.B x11vnc
[OPTION]...
......@@ -180,16 +180,18 @@ is taken as a floating point number, alternatively
the notation "m/n" may be used to denote fractions
exactly, e.g. \fB-scale\fR 2/3
.IP
Scaling Options: can be added after \fIfraction\fR via
":", to supply multiple ":" options use commas.
If you just want a quick, rough scaling without
blending, append ":nb" to \fIfraction\fR (e.g. \fB-scale\fR
1/3:nb). For compatibility with vncviewers the scaled
width is adjusted to be a multiple of 4: to disable
this use ":n4". More esoteric options: ":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).
Scaling Options: can be added after \fIfraction\fR
via ":", to supply multiple ":" options use
commas. If you just want a quick, rough scaling
without blending, append ":nb" to \fIfraction\fR
(e.g. \fB-scale\fR 1/3:nb). No blending is the default
for 8bpp indexed color, to force blending for this
case use ":fb". For compatibility with vncviewers
the scaled width is adjusted to be a multiple of 4:
to disable this use ":n4". More esoteric options:
":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
\fB-scale_cursor\fR \fIfrac\fR
.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
\fB-xwarppointer\fR option if the mouse pointer misbehaves.
.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
.IP
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 file use "\fB-oa\fR \fIfile\fR" or "\fB-logappend\fR \fIfile\fR".
.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
.IP
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,
or where window tearing is a problem.
.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
.IP
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
noxinerama disable \fB-xinerama\fR mode.
.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)
.IP
noxrandr disable \fB-xrandr\fR mode.
......@@ -1525,6 +1604,8 @@ snapfb enable \fB-snapfb\fR mode.
.IP
nosnapfb disable \fB-snapfb\fR mode.
.IP
rawfb:str set \fB-rawfb\fR mode to "str".
.IP
progressive:n set libvncserver \fB-progressive\fR slice
height parameter to n.
.IP
......@@ -1622,39 +1703,39 @@ scale_cursor viewonly noviewonly shared noshared
forever noforever once timeout deny lock nodeny unlock
connect allowonce allow localhost nolocalhost listen
lookup nolookup accept gone shm noshm flipbyteorder
noflipbyteorder onetile noonetile solid_color solid
nosolid blackout xinerama noxinerama xrandr noxrandr
xrandr_mode padgeom quiet q noquiet modtweak nomodtweak
xkb noxkb skip_keycodes add_keysyms noadd_keysyms
clear_mods noclear_mods clear_keys noclear_keys
remap repeat norepeat fb nofb bell nobell sel nosel
primary noprimary cursorshape nocursorshape cursorpos
nocursorpos cursor show_cursor noshow_cursor nocursor
arrow xfixes noxfixes xdamage noxdamage xd_area
xd_mem alphacut alphafrac alpharemove noalpharemove
alphablend noalphablend xwarp xwarppointer noxwarp
noxwarppointer buttonmap dragging nodragging
noflipbyteorder onetile noonetile solid_color
solid nosolid blackout xinerama noxinerama xtrap
noxtrap xrandr noxrandr xrandr_mode padgeom quiet q
noquiet modtweak nomodtweak xkb noxkb skip_keycodes
add_keysyms noadd_keysyms clear_mods noclear_mods
clear_keys noclear_keys remap repeat norepeat fb nofb
bell nobell sel nosel primary noprimary cursorshape
nocursorshape cursorpos nocursorpos cursor show_cursor
noshow_cursor nocursor arrow xfixes noxfixes xdamage
noxdamage xd_area xd_mem alphacut alphafrac alpharemove
noalpharemove alphablend noalphablend xwarp xwarppointer
noxwarp noxwarppointer buttonmap dragging nodragging
pointer_mode pm input_skip input client_input speeds
debug_pointer dp nodebug_pointer nodp debug_keyboard dk
nodebug_keyboard nodk deferupdate defer wait rfbwait
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
noalwaysshared nevershared noalwaysshared dontdisconnect
nodontdisconnect desktop noremote
.IP
aro= display vncdisplay desktopname http_url auth
users rootshift clipshift scale_str scaled_x scaled_y
scale_numer scale_denom scale_fac scaling_noblend
scaling_nomult4 scaling_pad scaling_interpolate inetd
safer unsafe passwdfile using_shm logfile o rc norc
h help V version lastmod bg sigpipe threads clients
client_count pid ext_xtest ext_xtrap ext_xkb ext_xshm
ext_xinerama ext_overlay ext_xfixes ext_xdamage
ext_xrandr rootwin num_buttons button_mask mouse_x
mouse_y bpp depth indexed_color dpy_x dpy_y wdpy_x
wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y rfbauth
passwd
scale_numer scale_denom scale_fac scaling_blend
scaling_nomult4 scaling_pad scaling_interpolate
inetd safer unsafe passwdfile using_shm logfile o
flag rc norc h help V version lastmod bg sigpipe
threads clients client_count pid ext_xtest ext_xtrap
ext_xkb ext_xshm ext_xinerama ext_overlay ext_xfixes
ext_xdamage ext_xrandr rootwin num_buttons button_mask
mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y
wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y
rfbauth passwd
.PP
\fB-sync\fR
.IP
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment