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-apps · 3.7 KB · 85 lines
| 1 | #!/bin/sh |
| 2 | # The dbbasic apps (Writer, Spreadsheet, Slides, Draw, Shell, Webmaster, |
| 3 | # Porter) on this desk: built binaries live on the desk in /desk/apps/NAME/ |
| 4 | # (or /opt/dbbasic/NAME without a desk), each with an nc-app.env manifest |
| 5 | # written by infra/apps.sh. This makes them part of the desktop: a menu |
| 6 | # entry, an icon, a command (dbbasic-NAME), and their file types, so a .dbw |
| 7 | # in ~/Objects or ~/Documents opens in Writer on a double click. |
| 8 | # |
| 9 | # nc-apps install (re)create entries for every app present; run by apply.sh |
| 10 | # nc-apps list |
| 11 | # |
| 12 | # Manifest (nc-app.env): NAME, TITLE, BINARY, COMMENT, CATEGORIES, |
| 13 | # EXTENSIONS (space separated), MIME (the type for them), ICON (a png in the |
| 14 | # bundle). |
| 15 | set -e |
| 16 | ROOT=/desk/apps; [ -d /desk/nc ] || ROOT=/opt/dbbasic |
| 17 | [ -f /etc/nc/env ] && . /etc/nc/env |
| 18 | case "$1" in |
| 19 | list) |
| 20 | for m in "$ROOT"/*/nc-app.env; do [ -f "$m" ] && (. "$m"; echo "$NAME $TITLE $ROOT/$NAME/$BINARY"); done |
| 21 | exit 0 ;; |
| 22 | install) ;; |
| 23 | *) echo "usage: nc-apps install|list"; exit 2 ;; |
| 24 | esac |
| 25 | |
| 26 | MIMEXML=/usr/share/mime/packages/dbbasic.xml |
| 27 | printf '<?xml version="1.0" encoding="UTF-8"?>\n<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">\n' > "$MIMEXML.new" |
| 28 | defaults="" |
| 29 | for m in "$ROOT"/*/nc-app.env; do |
| 30 | [ -f "$m" ] || continue |
| 31 | NAME= TITLE= BINARY= COMMENT= CATEGORIES= EXTENSIONS= MIME= ICON= |
| 32 | . "$m" |
| 33 | echo "$NAME" | grep -Eq '^[a-z][a-z0-9-]*$' || { echo "skipping $m: bad NAME"; continue; } |
| 34 | dir="$ROOT/$NAME" |
| 35 | [ -x "$dir/$BINARY" ] || { echo "skipping $NAME: no $dir/$BINARY"; continue; } |
| 36 | # the command every way of starting it goes through (menu, desktop icon, |
| 37 | # double-click, voice, a terminal). WebKitGTK's DMA-BUF renderer draws |
| 38 | # nothing on a computer without a GPU (a cloud desk): the editors' pages |
| 39 | # were blank while typing still worked (2026-09-25) |
| 40 | rm -f "/usr/local/bin/dbbasic-$NAME" |
| 41 | printf '#!/bin/sh\n# written by nc-apps\nexport WEBKIT_DISABLE_DMABUF_RENDERER=1\nexec %s "$@"\n' "'$dir/$BINARY'" > "/usr/local/bin/dbbasic-$NAME" |
| 42 | chmod 755 "/usr/local/bin/dbbasic-$NAME" |
| 43 | if [ -n "$ICON" ] && [ -f "$dir/$ICON" ]; then |
| 44 | install -Dm644 "$dir/$ICON" "/usr/share/icons/hicolor/512x512/apps/dbbasic-$NAME.png" |
| 45 | fi |
| 46 | mimeline="" |
| 47 | if [ -n "$MIME" ] && [ -n "$EXTENSIONS" ]; then |
| 48 | printf ' <mime-type type="%s">\n <comment>%s document</comment>\n' "$MIME" "$TITLE" >> "$MIMEXML.new" |
| 49 | for e in $EXTENSIONS; do printf ' <glob pattern="*.%s"/>\n' "$e" >> "$MIMEXML.new"; done |
| 50 | printf ' </mime-type>\n' >> "$MIMEXML.new" |
| 51 | mimeline="MimeType=$MIME;" |
| 52 | defaults="$defaults $MIME=dbbasic-$NAME.desktop" |
| 53 | fi |
| 54 | cat > "/usr/share/applications/dbbasic-$NAME.desktop" <<EOF |
| 55 | [Desktop Entry] |
| 56 | Type=Application |
| 57 | Name=$TITLE |
| 58 | Comment=$COMMENT |
| 59 | Exec=/usr/local/bin/dbbasic-$NAME %f |
| 60 | Icon=dbbasic-$NAME |
| 61 | Categories=$CATEGORIES |
| 62 | StartupWMClass=$BINARY |
| 63 | $mimeline |
| 64 | EOF |
| 65 | echo " $TITLE" |
| 66 | done |
| 67 | printf '</mime-info>\n' >> "$MIMEXML.new"; mv "$MIMEXML.new" "$MIMEXML" |
| 68 | update-mime-database /usr/share/mime >/dev/null 2>&1 || true |
| 69 | update-desktop-database /usr/share/applications >/dev/null 2>&1 || true |
| 70 | gtk-update-icon-cache -q /usr/share/icons/hicolor 2>/dev/null || true |
| 71 | |
| 72 | # on the desktop too, for a session that is running now (it also runs at login) |
| 73 | [ -n "$NC_DESK_USER" ] && nc-session-setup >/dev/null 2>&1 || true |
| 74 | |
| 75 | # the desk user's defaults for those types (their own later choices kept) |
| 76 | if [ -n "$NC_DESK_USER" ] && [ -n "$defaults" ]; then |
| 77 | U=$NC_DESK_USER; UHOME=$(getent passwd "$U" | cut -d: -f6) |
| 78 | L="$UHOME/.config/mimeapps.list" |
| 79 | for d in $defaults; do |
| 80 | t=${d%%=*} |
| 81 | grep -qs "^$t=" "$L" && continue |
| 82 | runuser -u "$U" -- sh -c "grep -qs '^\[Default Applications\]' '$L' || printf '[Default Applications]\n' >> '$L' |
| 83 | sed -i '/^\[Default Applications\]/a $d' '$L'" |
| 84 | done |
| 85 | fi |