bin/x2x-privsep: Add (souped-up) version of this handy script.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 8 Feb 2022 03:51:55 +0000 (03:51 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 8 Feb 2022 03:52:16 +0000 (03:52 +0000)
Makefile
bin/x2x-privsep [new file with mode: 0755]

index be1e688..a9a4ef2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -317,6 +317,7 @@ SCRIPTLINKS         += xinitcmd lock-screen xshutdown
 SCRIPTLINKS            += un-backslashify-selection
 SCRIPTLINKS            += xpra-start-xdummy
 SCRIPTLINKS            += play-rawk
+SCRIPTLINKS            += x2x-privsep
 SCRIPTLINKS            += xduplic-terminal
 
 DOTCPP                 += .Xdefaults
diff --git a/bin/x2x-privsep b/bin/x2x-privsep
new file mode 100755 (executable)
index 0000000..6d578e8
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh -ex
+
+dir=west bogus=nil
+usage () { echo "usage: $0 [-ensw] HOST:RDPY/LDPY"; }
+while getopts "hensw" opt; do
+  case $opt in
+    h) usage; exit ;;
+    e) dir=east ;;
+    n) dir=north ;;
+    s) dir=south ;;
+    w) dir=west ;;
+    *) bogus=t ;;
+  esac
+done
+shift $(( $OPTIND - 1))
+case $bogus,$#,$1 in nil,1,*:*/*) ;; *) usage >&2; exit 2 ;; esac
+host=${1%:*} dpy=${1##*:}; rdpy=${dpy%%/*} ldpy=${dpy#*/}
+control=ControlPath=~/.ssh/sock-%l/control-%r@%h.x2x
+ssh -o$control -L"/tmp/.X11-unix/X$ldpy:/tmp/.X11-unix/X$rdpy" -Nafx "$host"
+sleep 1
+trap 'trap - INT QUIT HUP EXIT; ssh -o$control -Oexit "$host"; rm -f "/tmp/.X11-unix/X$ldpy"' INT QUIT HUP EXIT
+x2x -$dir -to ":$ldpy"