Lanzador de escritorio: app con icono (modo portátil)
fosfeno-launcher.sh: arranca el servidor desacoplado, abre las visuales (ventana Chromium --app) y el panel, pensado para lanzarse con un icono (.desktop) sin terminal. `--stop` cierra servidor y ventana. Complementa a ./fosfeno (que sigue siendo el modo terminal, en primer plano con Ctrl+C). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3ec161562c
commit
0b1546cecc
1 changed files with 63 additions and 0 deletions
63
fosfeno-launcher.sh
Executable file
63
fosfeno-launcher.sh
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env bash
|
||||
# ===========================================================================
|
||||
# FOSFENO :: lanzador de escritorio (para el icono/app en Linux)
|
||||
#
|
||||
# A diferencia de ./fosfeno (que corre en primer plano y se cierra con Ctrl+C),
|
||||
# este arranca el servidor DESACOPLADO y abre las visuales + el panel, pensado
|
||||
# para lanzarse con doble clic desde el icono. No necesita terminal.
|
||||
#
|
||||
# ./fosfeno-launcher.sh arranca y abre FOSFENO
|
||||
# ./fosfeno-launcher.sh --stop cierra el servidor y la ventana de visuales
|
||||
# ===========================================================================
|
||||
set -u
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PORT="${FOSFENO_PORT:-8080}"
|
||||
URL="http://localhost:${PORT}/"
|
||||
|
||||
notify() {
|
||||
command -v notify-send >/dev/null 2>&1 && notify-send "FOSFENO" "$1" 2>/dev/null
|
||||
echo "FOSFENO: $1"
|
||||
}
|
||||
|
||||
# --- cerrar ---
|
||||
if [ "${1:-}" = "--stop" ]; then
|
||||
pkill -f "fosfeno-stage" 2>/dev/null # ventana de visuales (Chromium --app)
|
||||
pkill -f "backend/server.py" 2>/dev/null # servidor
|
||||
notify "cerrado."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- comprobaciones ---
|
||||
if [ ! -x "$DIR/.venv/bin/python3" ]; then
|
||||
notify "no está instalado. Ejecuta primero: bash install.sh --laptop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- servidor (desacoplado, solo si no responde ya) ---
|
||||
if ! curl -fsS -o /dev/null "$URL" 2>/dev/null; then
|
||||
FOSFENO_PORT="$PORT" FOSFENO_NO_KIOSK=1 \
|
||||
setsid "$DIR/.venv/bin/python3" "$DIR/backend/server.py" \
|
||||
> "$DIR/fosfeno-server.log" 2>&1 &
|
||||
# espera (hasta ~20 s) a que responda
|
||||
for _ in $(seq 1 40); do
|
||||
curl -fsS -o /dev/null "$URL" 2>/dev/null && break
|
||||
sleep 0.5
|
||||
done
|
||||
fi
|
||||
|
||||
# --- ventana de visuales (Chromium --app), solo si no está ya abierta ---
|
||||
BROWSER="$(command -v chromium-browser || command -v chromium \
|
||||
|| command -v google-chrome || true)"
|
||||
if [ -n "$BROWSER" ] && ! pgrep -f "fosfeno-stage" >/dev/null 2>&1; then
|
||||
setsid "$BROWSER" --app="${URL}stage" \
|
||||
--user-data-dir="/tmp/fosfeno-stage" \
|
||||
--use-fake-ui-for-media-stream \
|
||||
--autoplay-policy=no-user-gesture-required \
|
||||
>/dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
# --- panel de control en el navegador por defecto ---
|
||||
xdg-open "$URL" >/dev/null 2>&1 || true
|
||||
|
||||
notify "en marcha — panel en ${URL}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue