summaryrefslogtreecommitdiffstats
path: root/x11vnc/misc/enhanced_tightvnc_viewer/bin/tightvncviewer
blob: e4be75d293feb813a2715b608c50dd118c0397cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh
#
# Copyright (c) 2006 by Karl J. Runge <runge@karlrunge.com>
#
# tightvncviewer:
#
#    A wrapper that calls the enhanced TightVNC viewer. 
#
# The enhanced TightVNC viewer features are:
#
#	- SSL support for connections using the co-bundled stunnel program.
#	- rfbNewFBSize VNC support (screen resizing)
#	- cursor alphablending with x11vnc at 32bpp
#	- xgrabserver support for fullscreen mode (for old window mgrs)
#
#
# Your platform (e.g. Linux.i686) is autodetected and enhanced
# vncviewer and stunnel binaries for it are used (see the ./bin directory).
#
# See the build.unix script if your platform is not in this package if
# you want to build one.
#
# See the build.unix script if your platform is not in this package if you want to build one.
# You can also set the env. var. UNAME=os.arch to any "os.arch" you want
# to override the autodetetion.
#
# Usage:
#
#     tightvncviewer [tightvncviewer-args] hostname:N 
# or
#     tightvncviewer -ssl hostname:N [tightvncviewer-args]
#
# "hostname:N" is the host and VNC display to connect to, e.g. snoopy:0
#
# If the *very first* argument is "-cotvnc" then it is assumed you are on
# Darwin and want to run the Chicken of the VNC viewer via our wrapper.
#
# If the next argument is "-ssl" then ssl_tightvncviewer is called 
# instead.  See that script for details.
#
# See the TightVNC viewer documentation for on its cmdline arguments.
#
# For convenience, here is the current (7/2006) TightVNC viewer -help output:
#
#       TightVNC viewer version 1.3dev5
#       
#       Usage: vncviewer [<OPTIONS>] [<HOST>][:<DISPLAY#>]
#              vncviewer [<OPTIONS>] [<HOST>][::<PORT#>]
#              vncviewer [<OPTIONS>] -listen [<DISPLAY#>]
#              vncviewer -help
#       
#       <OPTIONS> are standard Xt options, or:
#               -via <GATEWAY>
#               -shared (set by default)
#               -noshared
#               -viewonly
#               -fullscreen
#               -noraiseonbeep
#               -passwd <PASSWD-FILENAME> (standard VNC authentication)
#               -user <USERNAME> (Unix login authentication)
#               -encodings <ENCODING-LIST> (e.g. "tight copyrect")
#               -bgr233
#               -owncmap
#               -truecolour
#               -depth <DEPTH>
#               -compresslevel <COMPRESS-VALUE> (0..9: 0-fast, 9-best)
#               -quality <JPEG-QUALITY-VALUE> (0..9: 0-low, 9-high)
#               -nojpeg
#               -nocursorshape
#               -x11cursor
#               -autopass
#       
#       Option names may be abbreviated, e.g. -bgr instead of -bgr233.
#       See the manual page for more information.
#  

if [ "X$1" = "X-h" -o "X$1" = "X-help" -o "X$1" = "X--help" ]; then
	head -76 "$0" | grep -v bin/sh
	exit
fi

# Include /usr/bin... to be sure to get regular utilities:
#
PATH=$PATH:/usr/bin:/bin
export PATH

# Set this for ssl_vncviewer to pick up:
#
use_ours=0
if [ "X$1" = "X-cotvnc" ]; then
	shift
	DARWIN_COTVNC=1
	export DARWIN_COTVNC
fi
if [ "X$VNCVIEWERCMD" = "X" ]; then
	VNCVIEWERCMD="vncviewer"
	export VNCVIEWERCMD
	if [ "X$DARWIN_COTVNC" = "X" ]; then
		use_ours=1
	fi
fi

# work out os.arch platform string and check for binaries:
#
name=$UNAME
if [ "X$name" = "X" ]; then
	name=`uname -sm | sed -e 's/ /./g'`
fi

f="$0"
for t in 1 2 3 4 5
do
	if [ -L "$f" ]; then
		f0="$f"
		f=`ls -l "$f" | sed -e 's/^.* -> //'`
		if echo "$f" | grep '^/' > /dev/null; then
			:
		else
			f="`dirname "$f0"`/$f"
		fi
	else
		break
	fi
done
dir=`dirname "$f"`

if [ ! -d "$dir/$name" ]; then
	echo "cannot find platform dir: $dir/$name for your OS:" 
	uname -sm
	echo "you can set the \$UNAME env. var. to override the setting."
	exit 1
fi

# Put our os.arch and other utils dirs at head of PATH to be sure to
# pick them up:
#
PATH="$dir:$dir/$name:$dir/util:$PATH"
if echo "$dir" | grep '^/' > /dev/null; then
	:
else
	dir=`pwd`/$dir
	PATH="$dir:$dir/$name:$dir/util:$PATH"
fi

STUNNEL_EXTRA_OPTS=${STUNNEL_EXTRA_OPTS:-"maxconn = 1"}
export STUNNEL_EXTRA_OPTS

if [ "X$1" = "X-ssl" ]; then
	shift	
	ssl_tightvncviewer "$@"
	exit $?
fi

# Force the use of tight encoding for localhost redir connection:
#
# If ours (and not doing cotvnc), force the use of tight encoding for
# the connection:
#
if [ $use_ours = 1 ]; then
	"$VNCVIEWERCMD" -encodings 'copyrect tight zrle zlib hextile' "$@"
else
	"$VNCVIEWERCMD" "$@"
fi