chiark / gitweb /
bin/, Makefile: Add some scripts for doing stuff to remote machines.
[profile] / bin / xremote
diff --git a/bin/xremote b/bin/xremote
new file mode 100755 (executable)
index 0000000..9aefdb9
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh -e
+
+case $#,$1 in
+  0,* | 1,*) ok=nil ;;
+  *,*:*) ok=t ;;
+  *) ok=nil ;;
+esac
+case $ok in
+  nil) echo >&2 "usage: $0 HOST:RDPY/LDPY PROG ARGS ..."; exit 2 ;;
+esac
+host=${1%:*} dpy=${1##*:}; rdpy=${dpy%%/*} ldpy=${dpy#*/}; shift 1
+
+ssh -L"/tmp/.X11-unix/X$ldpy:/tmp/.X11-unix/X$rdpy" -Nafx "$host"
+sleep 1
+trap 'trap - INT QUIT HUP EXIT; ssh -Oexit "$host"; rm -f "/tmp/.X11-unix/X$ldpy"' INT QUIT HUP EXIT
+DISPLAY=:$ldpy "$@"