summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-09-18 13:11:45 -0400
committerAndrew Cady <d@jerkface.net>2019-09-18 13:11:45 -0400
commit45556aef4dcc1ae78bbe68bc4842703d26f4763a (patch)
tree4c0fea105dc131c8de4b0253ab45960b290ee864
parent0cf72baacca747a95102a26001b245af3162d5d5 (diff)
xvnc: add option -r to share local display to remote side
-rwxr-xr-xdot/local/bin/xvnc46
1 files changed, 35 insertions, 11 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc
index 951c079..9bc982b 100755
--- a/dot/local/bin/xvnc
+++ b/dot/local/bin/xvnc
@@ -1,33 +1,57 @@
1#!/bin/sh 1#!/bin/sh
2remote_host=${1:-blackboard}
3remote_display=${2:-:0}
4local_display=${3:-0}
5 2
6direct_connection() 3direct_connection()
7{ 4{
8 port=$((5900 + local_display)) 5 port=$((5900 + local_display))
9 ssh -o ControlPath=none -n \ 6 ssh -o ControlPath=none -n \
10 -L $port:localhost:$port "$remote_host" 'x11vnc -nopw -ncache -ncache_cr -localhost -display :0' & 7 -L $port:localhost:$port "$remote_host" "x11vnc -nopw -ncache -ncache_cr -localhost -display ${remote_display}" &
11 pid=$! 8 pid=$!
12 sleep 1 # surrender race 9 sleep 1 # surrender race
13 xvncviewer -encodings "copyrect tight zrle hextile" localhost:0 10 xvncviewer -encodings "copyrect tight zrle hextile" localhost:0
14 kill $pid 11 kill $pid
15} 12}
16 13
14quietly()
15{
16 "$@" >/dev/null 2>&1
17}
18
17reverse_connection() 19reverse_connection()
18{ 20{
19 port=5500 21 port=5500
20 xvncviewer -fullscreen -encodings "copyrect tight zrle hextile" -listen & 22 xvncviewer -fullscreen -encodings "copyrect tight zrle hextile" -listen &
21 pid=$! 23 pid=$!
22 ssh -o ControlPath=none \ 24 quietly ssh -o ControlPath=none \
23 -R $port:localhost:$port "$remote_host" \ 25 -R $port:localhost:$port "$remote_host" \
24 "x11vnc -nopw -localhost -display ${remote_display} -coe localhost:$port -rfbport 0" \ 26 "x11vnc -q -nopw -localhost -display ${remote_display} -coe localhost:$port -rfbport 0"
25 >/dev/null 2>&1
26 kill $pid 27 kill $pid
27} 28}
28 29
29if [ "$USE_DIRECT_CONNECTION" ]; then 30share_display()
30 direct_connection 31{
32 set -x
33 port=5500
34 fuser -vk $port/tcp
35 ssh -o ControlPath=none \
36 -o ExitOnForwardFailure=yes \
37 -f \
38 -L $port:localhost:$port "$remote_host" \
39 "fuser -vk $port/tcp; DISPLAY=${remote_display} xvncviewer -fullscreen -encodings 'copyrect tight zrle hextile' -listen"
40 trap "fuser -vk $port/tcp" INT
41 sleep 1
42 x11vnc -q -nopw -localhost -display ${local_display} -coe localhost:$port -rfbport 0
43}
44
45if [ "$1" = -r ]
46then
47 shift
48 cmd=share_display
31else 49else
32 reverse_connection 50 cmd=reverse_connection
33fi 51fi
52
53remote_host=${1:-blackboard}
54remote_display=${2:-:0}
55local_display=${3:-:0}
56
57$cmd