SmartFox: launcher, Siri Remote driver, Debian image and installer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tamas Csikel
2026-10-24 09:06:06 +02:00
commit 79b03cac95
91 changed files with 15874 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
#!/bin/sh
# Hardware report for remote debugging: WiFi, GPU and rendering speed.
# ssh root@<IP> sf-diag > report.txt
# Read-only, changes nothing.
s() { printf '\n===== %s\n' "$*"; }
run() { s "$*"; "$@" 2>&1; }
run uname -a
run cat /proc/cmdline
run systemd-detect-virt
s "dmi"; cat /sys/class/dmi/id/sys_vendor /sys/class/dmi/id/product_name /sys/class/dmi/id/board_name /sys/class/dmi/id/bios_version 2>&1
# ---- WiFi
run lspci -nnk
run lsusb
run ip -br link
run rfkill list
run iw dev
run networkctl list
run systemctl --no-pager status iwd
run id tv
s "iwd D-Bus as tv (what the Wi-Fi settings see)"
runuser -u tv -- busctl --json=short call net.connman.iwd / org.freedesktop.DBus.ObjectManager GetManagedObjects 2>&1 | head -c 2000; echo
s "loaded wifi modules"; lsmod | grep -E 'iwl|rtw|rtl|mt7|ath|cfg80211|mac80211'
s "kernel log: wifi/firmware"
journalctl -k -b --no-pager | grep -iE 'firmware|iwlwifi|rtw|rtl8|mt79|mt76|ath1|wlan|wlp|cfg80211|regdom|pcie.*(error|fail)'
s "firmware files"; ls /lib/firmware | head -100
# ---- GPU and rendering
run ls -l /dev/dri
run id tv
s "kernel log: graphics"
journalctl -k -b --no-pager | grep -iE 'i915|xe |drm|guc|huc|dmc'
s "drm modes"
for c in /sys/class/drm/card*-*; do
[ "$(cat "$c/status" 2>/dev/null)" = connected ] || continue
echo "$c"; head -5 "$c/modes"
done
s "gpu / cpu clocks"
cat /sys/class/drm/card*/gt_cur_freq_mhz /sys/class/drm/card*/gt_max_freq_mhz 2>/dev/null
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null
run free -h
# ---- Standby / wake from suspend (Settings > Energia)
run cat /sys/power/state /sys/power/mem_sleep
s "acpi wakeup"; cat /proc/acpi/wakeup 2>&1
s "bluetooth controller wakeup"
for h in /sys/class/bluetooth/hci*; do
case "$h" in *:*) continue ;; esac
d=$(readlink -f "$h/device")
while [ -n "$d" ] && [ "$d" != / ] && [ "$d" != /sys/devices ]; do
[ -f "$d/power/wakeup" ] && echo "$d: $(cat "$d/power/wakeup")"
d=${d%/*}
done
done
command -v btmgmt >/dev/null && run btmgmt info
s "sf-remote: standby / suspend / wake"
journalctl -b --no-pager -u sf-remote | grep -iE 'standby|suspend|wake|power' | tail -40
s "kernel log: suspend / resume"
journalctl -k -b --no-pager | grep -iE 'PM: suspend|PM: resume|ACPI: PM|wake' | tail -30
# The cage session of user tv.
RT=/run/user/1000
for w in "$RT"/wayland-*; do
case "$w" in *.lock) continue ;; esac
[ -S "$w" ] || continue
s "wlr-randr ($w)"
runuser -u tv -- env XDG_RUNTIME_DIR="$RT" WAYLAND_DISPLAY="${w##*/}" wlr-randr 2>&1
s "eglinfo -B ($w)"
runuser -u tv -- env XDG_RUNTIME_DIR="$RT" WAYLAND_DISPLAY="${w##*/}" eglinfo -B -p wayland 2>&1 | head -40
break
done
s "launcher log (OpenGL, fps, errors)"
LOG=/var/home/tv/smartfox.log
grep -iE 'opengl|fps|error|warn|panic|llvmpipe|softpipe' "$LOG" 2>/dev/null | tail -60
s "launcher log tail"; tail -40 "$LOG" 2>/dev/null
s "top"; top -b -n1 | head -25

View File

@@ -0,0 +1,8 @@
#!/bin/sh
# Runs inside cage: apply the output mode, then start the launcher.
if [ -n "${SMARTFOX_MODE:-}" ]; then
OUT=$(wlr-randr | awk 'NR==1 {print $1}')
wlr-randr --output "$OUT" --custom-mode "$SMARTFOX_MODE" ||
echo "sf-launcher-start: could not set $SMARTFOX_MODE on $OUT"
fi
exec /usr/bin/sf-launcher --fullscreen --apps /usr/share/smartfox/apps

View File

@@ -0,0 +1,49 @@
#!/bin/sh
# Remote debugging switch: starts or stops sshd from the flag the launcher
# writes (Settings > System). Runs as root:
# sf-remote-debug the flag changed (sf-remote-debug.path)
# sf-remote-debug boot at boot (sf-remote-debug-boot.service)
# sf-remote-debug expire the time limit is up (transient timer)
#
# The flag holds "on" or "off". On real hardware ssh never stays on for long:
# it turns off after LIMIT and on every boot. In a VM it stays on without a
# flag and has no limit, because the dev tools (tools/vm) need ssh.
FLAG=/var/lib/smartfox/remote-debug
LIMIT=1h
TIMER=sf-remote-debug-off
vm() { systemd-detect-virt -q; }
stop_timer() {
systemctl stop "$TIMER.timer" 2>/dev/null
systemctl reset-failed "$TIMER.timer" "$TIMER.service" 2>/dev/null
}
off() {
stop_timer
exec systemctl --no-block stop ssh.service
}
case "${1:-}" in
boot | expire)
# Missing flag = off; tv owns the folder and can write it again.
vm && [ "$1" = boot ] || rm -f "$FLAG"
;;
esac
if [ -f "$FLAG" ]; then
state=$(cat "$FLAG")
elif vm; then
state=on
else
state=off
fi
[ "$state" = on ] || off
stop_timer
if ! vm; then
systemd-run --quiet --unit="$TIMER" --on-active="$LIMIT" --timer-property=AccuracySec=1s \
/usr/bin/sf-remote-debug expire
fi
exec systemctl --no-block start ssh.service

View File

@@ -0,0 +1,35 @@
#!/bin/sh
# SmartFox session: kiosk compositor (cage) with the launcher.
# Apps the launcher starts (Chromium etc.) appear full screen on top of it.
CONF="$HOME/.config/smartfox"
LOG="$HOME/smartfox.log"
# $HOME is on the data partition (/var). If it's missing, /var is the
# read-only root: still start the TV, just without saving anything.
if ! mkdir -p "$CONF" 2>/dev/null || ! touch "$LOG" 2>/dev/null; then
echo "sf-session: $HOME is read-only, settings will not be saved" >&2
CONF="$XDG_RUNTIME_DIR/smartfox"
LOG="$XDG_RUNTIME_DIR/smartfox.log"
mkdir -p "$CONF"
fi
[ -f "$CONF/settings.toml" ] || cp /usr/share/smartfox/settings.toml "$CONF/settings.toml"
export XDG_CONFIG_HOME="$(dirname "$CONF")"
export SMARTFOX_SOCKET="$XDG_RUNTIME_DIR/smartfox.sock"
export RUST_LOG="${RUST_LOG:-info}"
# No mouse on the TV: a transparent cursor theme (built in mkosi.postinst.chroot).
export XCURSOR_THEME=smartfox-blank XCURSOR_SIZE=24
# Output mode: the TV's preferred mode, except in VMs where the host window
# reports odd sizes. Override with SMARTFOX_MODE=WxH in /etc/default/smartfox.
[ -f /etc/default/smartfox ] && . /etc/default/smartfox
# Same, on the writable data partition (root is read-only), e.g. for debugging:
# echo 'RUST_LOG=sf_launcher=debug' > /var/lib/smartfox/session.env (fps every 5 s)
[ -f /var/lib/smartfox/session.env ] && . /var/lib/smartfox/session.env
export RUST_LOG
if [ -z "${SMARTFOX_MODE:-}" ] && systemd-detect-virt -q; then
SMARTFOX_MODE=1920x1080
fi
export SMARTFOX_MODE
exec cage -d -s -- /usr/bin/sf-launcher-start >>"$LOG" 2>&1

View File

@@ -0,0 +1,8 @@
# Writable data partition: created on first boot in the free space after the
# (read-only) root partition and mounted at /var (see /etc/fstab).
# Holds /var/home (settings, app profiles), Bluetooth pairings, logs.
[Partition]
Type=linux-generic
Label=sf-data
Format=ext4
SizeMinBytes=1G

View File

@@ -0,0 +1,18 @@
[Unit]
Description=SmartFox: fill the new data partition (/var) with the factory defaults
Documentation=file:/usr/lib/repart.d/50-sf-data.conf
DefaultDependencies=no
RequiresMountsFor=/var
ConditionPathIsMountPoint=/var
ConditionPathExists=!/var/.sf-data
After=local-fs.target
Before=sysinit.target systemd-tmpfiles-setup.service systemd-journal-flush.service systemd-random-seed.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/cp -a /usr/share/factory/var/. /var/
ExecStart=/bin/touch /var/.sf-data
[Install]
WantedBy=sysinit.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=SmartFox: remote debugging (ssh) off after boot
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/sf-remote-debug boot
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,9 @@
[Unit]
Description=SmartFox: watch the remote debugging switch
[Path]
PathModified=/var/lib/smartfox/remote-debug
Unit=sf-remote-debug.service
[Install]
WantedBy=paths.target

View File

@@ -0,0 +1,7 @@
[Unit]
Description=SmartFox: remote debugging (ssh) on or off
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/sf-remote-debug

View File

@@ -0,0 +1,13 @@
[Unit]
Description=SmartFox Siri Remote driver
After=bluetooth.service
Wants=bluetooth.service
[Service]
ExecStart=/usr/bin/sf-remote --home-socket /run/user/1000/smartfox.sock
Environment=RUST_LOG=info
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,2 @@
# The launcher (user tv) writes the remote debugging switch here.
d /var/lib/smartfox 0755 tv tv -

View File

@@ -0,0 +1 @@
netflex_server = "https://netflex.furbidden.cloud"