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.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/network-computer.git
HTTPS
https://gitstable.com/git/askrobots/network-computer.git
SSH
ssh://git@gitstable.com:2222/askrobots/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst Firefox policy: no WebRTC mDNS (a page using WebRTC made Firefox listen on UDP 5353) a1d92f3 1 month, 3 weeks ago History
keyboard.go · 2.4 KB · 80 lines
1package main
2
3import (
4 "log"
5 "os"
6 "os/exec"
7 "regexp"
8 "runtime"
9 "strings"
10)
11
12var layoutRe = regexp.MustCompile(`^[a-z]{2,3}(:[a-z0-9_-]{1,32})?$`)
13
14// setKeyboard applies a client's keyboard layout (Linux: nc-keyboard, which
15// records it on the desk and applies it to every keyboard now).
16func setKeyboard(layout string) {
17 if !layoutRe.MatchString(layout) {
18 log.Printf("keyboard: ignoring bad layout %q", layout)
19 return
20 }
21 if runtime.GOOS != "linux" {
22 return // macOS/Windows hosts use their own configured layout
23 }
24 out, err := exec.Command("nc-keyboard", layout).CombinedOutput()
25 if err != nil {
26 log.Printf("keyboard: nc-keyboard %s: %v %s", layout, err, strings.TrimSpace(string(out)))
27 return
28 }
29 log.Printf("keyboard: %s", strings.TrimSpace(string(out)))
30}
31
32// runInputHook lets provisioning adjust newly created input devices (the
33// desk's keyboard layout). Optional: absent on hosts without it.
34func runInputHook() {
35 if runtime.GOOS != "linux" {
36 return
37 }
38 p, err := exec.LookPath("nc-input-hook")
39 if err != nil {
40 return
41 }
42 if out, err := exec.Command(p).CombinedOutput(); err != nil {
43 log.Printf("input hook: %v %s", err, strings.TrimSpace(string(out)))
44 }
45}
46
47var tzRe = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9_+-]*(/[A-Za-z0-9_+-]+){0,2}$`)
48
49// setTimezone makes the desk's clock the client's: the taskbar clock, the
50// dashboard, and what voice takes "at 3" to mean. Linux desks only.
51func setTimezone(tz string) {
52 if runtime.GOOS != "linux" || !tzRe.MatchString(tz) || strings.Contains(tz, "..") {
53 return
54 }
55 if _, err := os.Stat("/usr/share/zoneinfo/" + tz); err != nil {
56 log.Printf("timezone: unknown %q", tz)
57 return
58 }
59 if cur, _ := os.Readlink("/etc/localtime"); strings.HasSuffix(cur, "/"+tz) {
60 return
61 }
62 if out, err := exec.Command("timedatectl", "set-timezone", tz).CombinedOutput(); err != nil {
63 log.Printf("timezone: %v %s", err, strings.TrimSpace(string(out)))
64 return
65 }
66 log.Printf("timezone: %s (from the client)", tz)
67 // the taskbar clock reads the zone when it starts
68 exec.Command("nc-as-user", "xfce4-panel", "-r").Start()
69}
70
71// launch opens (or closes) the desk's search and launch bar, for the client's
72// 🔍 button. Linux desks only: nc-launch comes with provisioning.
73func launch() {
74 if runtime.GOOS != "linux" {
75 return
76 }
77 if out, err := exec.Command("nc-launch").CombinedOutput(); err != nil {
78 log.Printf("launch: %v %s", err, strings.TrimSpace(string(out)))
79 }
80}