diff options
Diffstat (limited to 'dot')
-rwxr-xr-x | dot/local/bin/xvnc | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc index 957fa2b..e1e99a1 100755 --- a/dot/local/bin/xvnc +++ b/dot/local/bin/xvnc | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | # x11vnc option '-noxrecord' added as workaround for crashing bug | 3 | # x11vnc option '-noxrecord' added as workaround for crashing bug |
4 | # See https://github.com/LibVNC/x11vnc/issues/61 | 4 | # See https://github.com/LibVNC/x11vnc/issues/61 |
@@ -40,6 +40,49 @@ reverse_connection() | |||
40 | kill $pid | 40 | kill $pid |
41 | } | 41 | } |
42 | 42 | ||
43 | ssh() | ||
44 | { | ||
45 | command ssh "$@" 2>&1 | sed 's/^/REMOTE> /' | ||
46 | } | ||
47 | |||
48 | share_display_direct() | ||
49 | { | ||
50 | if [ "$DEBUG" ] | ||
51 | then | ||
52 | set -x | ||
53 | fi | ||
54 | |||
55 | port=5500 | ||
56 | while fuser -vk $port/tcp | ||
57 | do | ||
58 | sleep 0.1 | ||
59 | done | ||
60 | x11vnc -noxrecord -q -nopw -ncache -ncache_cr -localhost -display "${local_display}" -rfbport "$port" & | ||
61 | X11VNC=$! | ||
62 | trap 'if [ ! "$DEBUG" ]; then exec 2>/dev/null; fi; set -- "$X11VNC" "$SSH"; ps hu "$@"; kill "$@"' EXIT | ||
63 | |||
64 | while ! fuser -v $port/tcp | ||
65 | do | ||
66 | [ -e /proc/"$X11VNC" ] || break | ||
67 | sleep 0.1 | ||
68 | done | ||
69 | |||
70 | # TODO: spin waiting for port 5500 | ||
71 | ssh -n \ | ||
72 | ${remote_port:+ -p "$remote_port" } \ | ||
73 | "$remote_host" \ | ||
74 | "fuser -vk $port/tcp && sleep 1" | ||
75 | ssh -n \ | ||
76 | -o ControlPath=none \ | ||
77 | -o ExitOnForwardFailure=yes \ | ||
78 | -R "localhost:$port:localhost:$port" \ | ||
79 | ${remote_port:+ -p "$remote_port" } \ | ||
80 | "$remote_host" \ | ||
81 | "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 & | ||
82 | SSH=$! | ||
83 | wait -n | ||
84 | } | ||
85 | |||
43 | share_display() | 86 | share_display() |
44 | { | 87 | { |
45 | set -x | 88 | set -x |
@@ -60,13 +103,14 @@ share_display() | |||
60 | if [ "$1" = -r ] | 103 | if [ "$1" = -r ] |
61 | then | 104 | then |
62 | shift | 105 | shift |
63 | cmd=share_display | 106 | cmd=share_display_direct |
64 | elif [ "$1" = -d ] | 107 | elif [ "$1" = -d ] |
65 | then | 108 | then |
66 | shift | 109 | shift |
67 | cmd=direct_connection | 110 | cmd=direct_connection |
68 | else | 111 | else |
69 | cmd=reverse_connection | 112 | # cmd=reverse_connection |
113 | cmd=direct_connection | ||
70 | fi | 114 | fi |
71 | 115 | ||
72 | remote_host=${1:-blackboard} | 116 | remote_host=${1:-blackboard} |