The TUI is now a TypeScript/opentui app in tui/ rather than Bubble Tea.
opentui is a Zig core with TypeScript bindings and no Go bindings, so this half
of the tool can't live in the Go binary; it compiles with Bun into a sibling
executable (rtsp-streamer-tui) that `rtsp-streamer tui` execs.
Everything that isn't presentation stays in Go, reached over three JSON
commands. The configurator holds no credentials and never writes the config
itself:
config export the config, plus limits like max_tiles
config apply (stdin) merge cameras/layouts/active_layout, validate, save
atomically, reload the daemon
discover --json Protect discovery, writing nothing
Two properties of that split are deliberate:
- The controller password never crosses the bridge. It's json:"-" on the way
out, and apply only merges the three keys the TUI edits, so it can't be
clobbered on the way back in either.
- apply re-reads the file before merging, so an editor left open for an hour can
no longer overwrite a `views import`, a `layout set`, or a hand edit made in
the meantime.
Discovery is previewable as a result: `discover --json` writes nothing, the
merge happens in the TUI, and nothing reaches disk until you save. Only
--enable-rtsp has a side effect, and it's on the controller.
Config structs gain json tags mirroring their yaml ones so the config
round-trips through the bridge under the same key names it has on disk, and
maxGridDim moves to config.MaxGridDim so the CLI and both configurators enforce
one ceiling. The write path is byte-for-byte identical to `layout set`, checked
against a copy of a live config.
Visible change: the grid editor draws real bordered boxes, so a spanning tile is
one box instead of an origin cell plus "·" continuation marks, and the
header-offset arithmetic in mouse.go is gone — the framework hit-tests list
rows. Keybindings, the lipgloss palette and the screen flow are carried over
unchanged; S now saves from anywhere.
The Bubble Tea version stays as `tui --legacy`. It's compiled into the Go binary
and needs no Bun, and on a headless Pi the TUI is the only config UI there is,
so a fallback is worth its weight. The cost of the new one is size: ~120 MB
against ~13 MB, since Bun embeds its runtime and opentui's native library.
Tests: 67 bun tests drive the real (in-memory) opentui renderer, including mouse
click and drag, plus tsc --noEmit. `make test-tui` runs both, and
scripts/preview.ts dumps every screen as text without needing a terminal.
Three bugs found during the port are documented in tui/README.md, since none are
apparent from the code: overlapping cell borders render as ┌ where a lattice
needs ┬; a drag dies after the first resize if the tree is rebuilt, because the
renderer captures the press-target renderable; and a rebuilt box has no computed
layout until the next frame, so its screenX reads 0.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
100 lines
3.8 KiB
Bash
Executable File
100 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install rtsp-streamer as a boot-to-wall kiosk. Run as root on the target
|
|
# (Raspberry Pi 4 or any Linux with sway + mpv).
|
|
#
|
|
# sudo ./deploy/install.sh [kiosk-user]
|
|
#
|
|
# Steps performed:
|
|
# * install the rtsp-streamer binary to /usr/local/bin
|
|
# * install the kiosk sway config to /etc/rtsp-streamer/sway/config
|
|
# * create the kiosk user (if missing) and add it to the video/render/input seats
|
|
# * enable tty1 autologin for that user
|
|
# * append the sway launcher to the user's ~/.bash_profile
|
|
#
|
|
# It does NOT install sway/mpv — do that with your distro's package manager:
|
|
# Debian/RPi OS: apt install sway mpv foot
|
|
# Arch: pacman -S sway mpv foot
|
|
set -euo pipefail
|
|
|
|
KIOSK_USER="${1:-kiosk}"
|
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BIN_SRC="${REPO_DIR}/bin/rtsp-streamer"
|
|
# The configurator is a separate, optional binary (built with Bun; see
|
|
# tui/README.md). Accept either the host build or the arm64 cross-build.
|
|
TUI_SRC="${REPO_DIR}/bin/rtsp-streamer-tui"
|
|
[ -x "$TUI_SRC" ] || TUI_SRC="${REPO_DIR}/bin/rtsp-streamer-tui-arm64"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "error: run as root (sudo)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -x "$BIN_SRC" ]; then
|
|
echo "error: ${BIN_SRC} not found. Build it first: make build (native) or make pi (arm64)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo ">> installing binary to /usr/local/bin/rtsp-streamer"
|
|
install -m 0755 "$BIN_SRC" /usr/local/bin/rtsp-streamer
|
|
|
|
# Installed under the un-suffixed name, which is what `rtsp-streamer tui` looks
|
|
# for next to itself.
|
|
if [ -x "$TUI_SRC" ]; then
|
|
echo ">> installing configurator to /usr/local/bin/rtsp-streamer-tui"
|
|
install -m 0755 "$TUI_SRC" /usr/local/bin/rtsp-streamer-tui
|
|
else
|
|
echo ">> no configurator binary found (build it with 'make tui'); "
|
|
echo " 'rtsp-streamer tui --legacy' will still work."
|
|
fi
|
|
|
|
echo ">> installing sway kiosk config to /etc/rtsp-streamer/sway/config"
|
|
install -d /etc/rtsp-streamer/sway
|
|
install -m 0644 "${REPO_DIR}/deploy/sway/config" /etc/rtsp-streamer/sway/config
|
|
|
|
if ! id "$KIOSK_USER" >/dev/null 2>&1; then
|
|
echo ">> creating user ${KIOSK_USER}"
|
|
useradd --create-home --shell /bin/bash "$KIOSK_USER"
|
|
fi
|
|
echo ">> adding ${KIOSK_USER} to video/render/input groups"
|
|
for grp in video render input seat; do
|
|
getent group "$grp" >/dev/null 2>&1 && usermod -aG "$grp" "$KIOSK_USER" || true
|
|
done
|
|
|
|
echo ">> enabling tty1 autologin for ${KIOSK_USER}"
|
|
install -d /etc/systemd/system/getty@tty1.service.d
|
|
sed "s/kiosk/${KIOSK_USER}/" "${REPO_DIR}/deploy/systemd/getty@tty1.service.d/autologin.conf" \
|
|
> /etc/systemd/system/getty@tty1.service.d/autologin.conf
|
|
systemctl daemon-reload
|
|
|
|
HOME_DIR="$(getent passwd "$KIOSK_USER" | cut -d: -f6)"
|
|
PROFILE="${HOME_DIR}/.bash_profile"
|
|
MARKER="# >>> rtsp-streamer kiosk launcher >>>"
|
|
if ! grep -qF "$MARKER" "$PROFILE" 2>/dev/null; then
|
|
echo ">> appending sway launcher to ${PROFILE}"
|
|
{
|
|
echo ""
|
|
echo "$MARKER"
|
|
cat "${REPO_DIR}/deploy/profile-snippet.sh"
|
|
echo "# <<< rtsp-streamer kiosk launcher <<<"
|
|
} >> "$PROFILE"
|
|
chown "$KIOSK_USER": "$PROFILE"
|
|
else
|
|
echo ">> launcher already present in ${PROFILE}, leaving it"
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
Done. Next steps:
|
|
1. Put a config at ${HOME_DIR}/.config/rtsp-streamer/config.yaml
|
|
(as ${KIOSK_USER}: rtsp-streamer config init then edit it, or run
|
|
rtsp-streamer tui — add --legacy if the configurator wasn't installed).
|
|
2. Export the controller password for the daemon. Easiest: create
|
|
${HOME_DIR}/.config/rtsp-streamer/env with RTSP_STREAMER_PASSWORD=...
|
|
and source it from ~/.bash_profile before sway starts.
|
|
3. Discover cameras: sudo -u ${KIOSK_USER} rtsp-streamer discover
|
|
4. Reboot, or switch to tty1, to bring up the wall.
|
|
|
|
Make sure 'sway' and 'mpv' are installed. Verify a stream first with:
|
|
mpv --rtsp-transport=tcp 'rtsps://HOST:7441/ALIAS?enableSrtp'
|
|
EOF
|