diff options
author | Andrew Cady <d@jerkface.net> | 2018-07-27 10:52:56 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-07-27 10:52:56 -0400 |
commit | 191034467f9ff8b649b6c659243d33d35e69f889 (patch) | |
tree | 96f2cb502010d88dea763a0f9a46e0a141d97ad0 /dot/local | |
parent | 9938e90e3452195f407243bc76cf6dee56916392 (diff) |
xvnc
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/xvnc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc new file mode 100755 index 0000000..951c079 --- /dev/null +++ b/dot/local/bin/xvnc | |||
@@ -0,0 +1,33 @@ | |||
1 | #!/bin/sh | ||
2 | remote_host=${1:-blackboard} | ||
3 | remote_display=${2:-:0} | ||
4 | local_display=${3:-0} | ||
5 | |||
6 | direct_connection() | ||
7 | { | ||
8 | port=$((5900 + local_display)) | ||
9 | ssh -o ControlPath=none -n \ | ||
10 | -L $port:localhost:$port "$remote_host" 'x11vnc -nopw -ncache -ncache_cr -localhost -display :0' & | ||
11 | pid=$! | ||
12 | sleep 1 # surrender race | ||
13 | xvncviewer -encodings "copyrect tight zrle hextile" localhost:0 | ||
14 | kill $pid | ||
15 | } | ||
16 | |||
17 | reverse_connection() | ||
18 | { | ||
19 | port=5500 | ||
20 | xvncviewer -fullscreen -encodings "copyrect tight zrle hextile" -listen & | ||
21 | pid=$! | ||
22 | ssh -o ControlPath=none \ | ||
23 | -R $port:localhost:$port "$remote_host" \ | ||
24 | "x11vnc -nopw -localhost -display ${remote_display} -coe localhost:$port -rfbport 0" \ | ||
25 | >/dev/null 2>&1 | ||
26 | kill $pid | ||
27 | } | ||
28 | |||
29 | if [ "$USE_DIRECT_CONNECTION" ]; then | ||
30 | direct_connection | ||
31 | else | ||
32 | reverse_connection | ||
33 | fi | ||