summaryrefslogtreecommitdiff
path: root/dot
diff options
context:
space:
mode:
Diffstat (limited to 'dot')
-rwxr-xr-xdot/local/bin/xvnc50
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
43ssh()
44{
45 command ssh "$@" 2>&1 | sed 's/^/REMOTE> /'
46}
47
48share_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
43share_display() 86share_display()
44{ 87{
45 set -x 88 set -x
@@ -60,13 +103,14 @@ share_display()
60if [ "$1" = -r ] 103if [ "$1" = -r ]
61then 104then
62 shift 105 shift
63 cmd=share_display 106 cmd=share_display_direct
64elif [ "$1" = -d ] 107elif [ "$1" = -d ]
65then 108then
66 shift 109 shift
67 cmd=direct_connection 110 cmd=direct_connection
68else 111else
69 cmd=reverse_connection 112 # cmd=reverse_connection
113 cmd=direct_connection
70fi 114fi
71 115
72remote_host=${1:-blackboard} 116remote_host=${1:-blackboard}