Files
os/image/mkosi.extra/usr/bin/sf-session
Tamas Csikel 9c710bedb9 Fennec OS 0.3.2: one app at a time, Raspberry Pi shell packages
- sf-core: only one app runs. Home, another app or a cast closes the app
  on screen (after the switch animation) instead of freezing it in the
  background. A frozen app that held a sound stream stalled PipeWire, so
  the next app could not play at all ("Failed to connect stream: No such
  entity" in Netflex after YouTube was sent home mid-video). The
  background limit and the low-memory watcher go with the freezing.
- Raspberry Pi: image/pi (installer on Raspberry Pi OS), aarch64 shell
  packages (sf-shell-<v>-aarch64, arch in pkg.toml, sf-update installs only
  its own architecture), CI builds the aarch64 shell too.
- sf-compositor: volume OSD, screencopy for remote view, blank cursor.
- SDK v0.1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 19:38:09 +01:00

51 lines
2.4 KiB
Bash

#!/bin/sh
# Fennec OS 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 ] && { set -a; . /etc/default/smartfox; set +a; }
# Same, on the writable data partition (root is read-only); every variable
# set in these files is passed on. 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 ] && { set -a; . /var/lib/smartfox/session.env; set +a; }
export RUST_LOG
# Remote viewing for development (wayvnc, README "Távoli képernyő (VNC)").
export SMARTFOX_REMOTE_VIEW="${SMARTFOX_REMOTE_VIEW:-0}"
export SMARTFOX_VNC_ARGS="${SMARTFOX_VNC_ARGS:-}"
if [ -z "${SMARTFOX_MODE:-}" ] && systemd-detect-virt -q; then
SMARTFOX_MODE=1920x1080
fi
export SMARTFOX_MODE
# The compositor: sf-compositor (app switching, volume OSD). If it can't start
# (or crashes right away), fall back to cage so the TV still works.
# SMARTFOX_COMPOSITOR=cage in /etc/default/smartfox or session.env forces cage.
if [ "${SMARTFOX_COMPOSITOR:-sf-compositor}" != cage ]; then
start=$(date +%s)
/usr/bin/sf-shell-exec sf-compositor --drm -- /usr/bin/sf-launcher-start >>"$LOG" 2>&1 && exit 0
if [ $(($(date +%s) - start)) -gt 20 ]; then
exit 1 # ran for a while: a normal exit/crash, getty restarts the session
fi
echo "sf-session: sf-compositor failed, falling back to cage" >>"$LOG"
fi
exec cage -d -s -- /usr/bin/sf-launcher-start >>"$LOG" 2>&1