qubes.ShowInTerminal 440 B

1234567891011121314151617181920
  1. #!/bin/bash --
  2. set -eu
  3. umask 0077
  4. tmpdir="$(mktemp -d)"
  5. if ! [[ $tmpdir =~ ^/[/A-Za-z0-9._-]+$ ]]; then
  6. echo 'Error: non admissible character detected in sock path.'>&2
  7. exit 1
  8. fi
  9. sock="$tmpdir/terminal.sock"
  10. xterm -geometry 80x24 -e /bin/sh -c "
  11. until [ -S $sock ]; do sleep 0.1; done || true
  12. exec socat file:/dev/tty,rawer,escape=0x0f UNIX-CONNECT:$sock" &
  13. trap 'rm -rf -- "$tmpdir"' EXIT
  14. socat "UNIX-LISTEN:\"$sock\"" -
  15. wait