askrobots / network-computer
Public
Your phone is the terminal. Stream a Linux/Mac desktop to an iPhone over WebRTC through NAT, with audio and input. Open source, single binaries.
Dan Quellhorst
Firefox policy: no WebRTC mDNS (a page using WebRTC made Firefox listen on UDP 5353)
a1d92f3
1 month, 3 weeks ago
History
nc-send · 999 bytes · 17 lines
| 1 | #!/bin/sh |
| 2 | # Send files to the device you are connected from; it offers each as a download. |
| 3 | # nc-send FILE... (also the file manager's right-click "Send to my device") |
| 4 | SOCK=${NC_SEND_SOCKET:-/run/nc-host/send.sock} |
| 5 | say() { echo "$1"; command -v notify-send >/dev/null && notify-send -i document-send "Send to my device" "$1"; } |
| 6 | [ $# -gt 0 ] || { echo "usage: nc-send FILE..."; exit 2; } |
| 7 | [ -S "$SOCK" ] || { say "nc-host is not running here"; exit 1; } |
| 8 | rc=0 |
| 9 | for f in "$@"; do |
| 10 | if [ ! -f "$f" ] || [ ! -r "$f" ]; then say "$(basename "$f"): not a readable file (folders: zip them first)"; rc=1; continue; fi |
| 11 | name=$(basename "$f") |
| 12 | q=$(python3 -c 'import sys,urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$name") |
| 13 | out=$(curl -sS --unix-socket "$SOCK" -T "$f" -w '\n%{http_code}' "http://desk/send?name=$q" 2>&1) |
| 14 | code=$(echo "$out" | tail -n 1); body=$(echo "$out" | sed '$d') |
| 15 | if [ "$code" = 200 ]; then say "$body"; else say "$name: ${body:-not sent}"; rc=1; fi |
| 16 | done |
| 17 | exit $rc |