diff --git a/.gitignore b/.gitignore index abe0eab..abe44cf 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,20 @@ webapp/storage/data/*.manual /webapp/storage/framework/views/ /webapp/bootstrap/cache/*.php +# archived/ — old machine-local generated files that came along when the +# legacy scene dirs were moved. The hand-authored HTML / JSON sources are +# tracked; only the script-generated wrappers and runtime state aren't. +archived/scenes/landing/telemetry.js +archived/scenes/landing/*.manual +archived/scenes/loading/loading.json +archived/scenes/loading/loading.js +archived/scenes/loading/playlist.json +archived/scenes/loading/playlist.js +archived/scenes/loading/cmd.js +archived/scenes/loading/*.manual +archived/scenes/loading/playlist/ +archived/vendor/obs-config.js + # ============================================================ # OBS runtime / generated state — no value in version control # ============================================================ diff --git a/CLAUDE.md b/CLAUDE.md index ece5275..9ca7973 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Current state (read this first) -Active OBS Studio config dir for the **ophi118** Twitch streaming rig. It hosts: six scenes (Landing, Project Loading, Game, Desktop, Music Box, Good Bye), six custom HTML/CSS/JS overlays rendered as `browser_source`, an MPD-based audio architecture with a state bridge to OBS WebSocket, a Twitch chat bot that controls MPD via `!skip`/`!queue`/`!info`, and an optional Mattermost notifier that posts when the channel goes live. Two rigs share this codebase via a single git repo: **Ignia** (current) and **Midgolem** (deployment target). +Active OBS Studio config dir for the **ophi118** Twitch streaming rig. It hosts: six scenes (Landing, Project Loading, Game, Desktop, Music Box, Good Bye), a Laravel webapp (`webapp/`) that serves the scene overlays over `http://127.0.0.1:1118/` under supervisord, an MPD-based audio architecture with `bridges/mpd-state.py` re-broadcasting MPD state as `mpd:state` events over OBS WebSocket, a Twitch chat bot that controls MPD via `!skip`/`!queue`/`!info`, and an optional Mattermost notifier that posts when the channel goes live. Two rigs share this codebase via a single git repo: **Ignia** (current) and **Midgolem** (deployment target). ## What this directory is @@ -32,38 +32,59 @@ Or via the app menu ("OBS Studio"). The native `obs` binary still exists from `p - `plugin_manager/modules.json` — third-party plugins OBS loads. - `logs/`, `profiler_data/`, `.sentinel/` — runtime state. -**Custom overlays (browser sources rendering local HTML — safe to edit while OBS is up):** -- `landing/` — Fallout-style "PLEASE STAND BY" overlay + telemetry + 12 s static-hum loop. -- `loading/` — terminal-style Project Loading overlay + per-session manifest + flat playlist index + legacy `cmd.js`. -- `game/index.html` — Game scene HUD (TRANSMISSION ID, signal, clock, camera frame, status bar). Live-syncs camera transform via OBS WS. -- `desktop/index.html` — Desktop scene HUD, forked from Game (no game-name slot, no music widget — that lives below the camera as a separate source). -- `goodbye/index.html` — sign-off overlay. -- `music-box/index.html` — full-screen Music Box terminal (scrolling `[audio]` log + pinned 3-up next + chat help strip). -- `music-box/widget.html` — compact 549×880 sidebar widget for the Desktop scene. **Authored at native pixel size** (`bounds_type: 0`, no stretch). -- `music/index.html` — legacy "Music Daemon" browser source. -- `vendor/obs-ws-mini.js` — minimal OBS WebSocket v5 client. `vendor/obs-config.js` is the auto-generated WS connection config (gitignored). +**Scene overlays (`webapp/` — Laravel app served on 127.0.0.1:1118 by supervisord):** +- `webapp/resources/views/overlays/landing.blade.php` — Fallout-style "PLEASE STAND BY" overlay + telemetry rotator. +- `webapp/resources/views/overlays/loading.blade.php` — terminal-style Project Loading overlay + countdown. +- `webapp/resources/views/overlays/game.blade.php` — Game HUD (camera-frame OBS-WS sync, status bar). +- `webapp/resources/views/overlays/desktop.blade.php` — Desktop HUD (camera + screen-capture frames). +- `webapp/resources/views/overlays/goodbye.blade.php` — sign-off terminal + "OFFLINE FOR" counter. +- `webapp/resources/views/overlays/music/box.blade.php` — full-screen Music Box terminal. +- `webapp/resources/views/overlays/music/widget.blade.php` — compact 549×880 widget (`bounds_type: 0`, no stretch). +- `webapp/resources/views/overlays/music/cover.blade.php` — album-art widget (`?bars=0` for compact mode). +- `webapp/resources/views/overlays/music/nc.blade.php` — ncurses-styled 2-pane Music Box. +- `webapp/resources/views/overlays/music/daemon.blade.php` — passive diagnostic; playback is handled by MPD + `bridges/mpd-state.py`. +- `webapp/public/css/hud.css` — extracted shared HUD chrome, scanlines, terminal styling, pulse keyframes. +- `webapp/public/js/{hud,crt-static,obs-ws-bootstrap,obs-ws-mini}.js` — shared JS; `obs-config.js` is gitignored, generated by `php artisan rig:setup`. +- Routes + controllers under `webapp/app/Http/Controllers/`. See `routes/web.php` for the URL → handler table. + +**Artisan commands (replace the old bash helpers — see `archived/scripts/`):** +- `php artisan rig:setup` — generate `webapp/public/js/obs-config.js` + `OBS_WS_*` env from `plugin_config/obs-websocket/config.json`. +- `php artisan rig:telemetry [--collect]` — refresh hardware/OBS-profile snapshot at `webapp/storage/data/telemetry.json`. +- `php artisan rig:loading` — interactive manifest builder; updates Twitch channel via Helix (no Python shell-out). +- `php artisan rig:playlist` — index audio dirs with ffprobe → `webapp/storage/data/playlist.json`. +- `php artisan rig:cmd ` — broadcast `mpd:cmd` over OBS WS (CLI mirror of `POST /cmd/{type}`). **Audio + automation surfaces:** -- `bridges/mpd-state.py` — MPD → OBS WS state bridge (`obs-mpd-bridge.service`). -- `twitch-bot/bot.py` — Twitch chat bot for `!skip` / `!queue` / `!info` + optional Mattermost going-live notifier (`obs-twitch-bot.service`). -- `twitch-bot/{search-game,set-channel,_twitch}.py` — Helix helpers used by `scripts/loading.sh`. +- `bridges/mpd-state.py` — MPD → OBS WS state bridge (`obs-mpd-bridge.service`). Writes `bridges/cover.jpg`. Authoritative source of `mpd:state` events. +- `twitch-bot/bot.py` — Twitch chat bot for `!skip` / `!queue` / `!info`. Talks to MPD directly, not via OBS WS. +- `twitch-bot/{search-game,set-channel,_twitch}.py` — Helix helpers (still present; `rig:loading` no longer needs them — it uses Guzzle directly). - `twitch-bot/.env*` — secrets (per-rig, never copy). **Scripts (`.sh` lives only here):** -- `scripts/deploy-rig.sh` — idempotent bring-up for a fresh rig. -- `scripts/setup.sh` — generate `vendor/obs-config.js` after a WS password change. -- `scripts/telemetry.sh` — refresh `landing/telemetry.json` + wrap to `.js`. -- `scripts/loading.sh` — interactive `loading.json` builder; pushes title/category to Twitch. -- `scripts/playlist.sh` — playlist sync + legacy daemon control. +- `scripts/deploy-rig.sh` — idempotent bring-up for a fresh rig (now also installs the supervisord program + runs `composer install`). +- `scripts/obs-webapp.supervisord.conf` — supervisord program file; install to `/etc/supervisor.d/obs-webapp.conf`. +- `scripts/rewrite-scene-urls.py` — one-shot tool that rewrote `basic/scenes/Default_Stream_HUD.json` from `file://` to `http://127.0.0.1:1118/...` URLs during migration. Idempotent. - `scripts/convert.sh`, `scripts/clean.sh` — yt-dlp `.webm` → AAC `.m4a` re-encode + audit. -**Reference / data:** `playlist/` (gitignored library), `profile/` (rig spec docs), `station/` (git submodule for the public rig-spec page). +**Reference / archive:** `archived/` (pre-migration scenes + bash scripts + `vendor/`, kept for rollback — see `archived/README.md`). `playlist/` (gitignored audio library). `profile/` (rig spec docs). `station/` (submodule for the public rig-spec page). + +## How OBS reaches the overlays — supervisord + Laravel + +OBS browser sources point at `http://127.0.0.1:1118/` (rewritten from the old `file://...` URLs by `scripts/rewrite-scene-urls.py`). The Laravel app runs under supervisord: + +``` +sudo supervisorctl status obs-webapp # → RUNNING +sudo supervisorctl restart obs-webapp # after route / controller / .env changes +tail -F webapp/storage/logs/supervisord.{out,err}.log +``` + +The program file is `scripts/obs-webapp.supervisord.conf`; the installed copy is at `/etc/supervisor.d/obs-webapp.conf` (root-owned). ## Critical gotcha: OBS overwrites on exit OBS rewrites `basic/scenes/.json`, `global.ini`, and `user.ini` on shutdown (and periodically). **Close OBS before editing these files**, or the next OBS exit will clobber the edit. After editing, re-launch OBS to load the change. -**HTML overlays under `landing/`, `loading/`, `game/`, `desktop/`, `goodbye/`, `music-box/`, `music/` are safe to edit while OBS is up** — CEF re-reads them on demand. Apply the change with right-click source → **Refresh cache** in OBS, no restart needed. +**Blade views under `webapp/resources/views/overlays/` are safe to edit while OBS is up** — CEF re-fetches on right-click source → **Refresh cache** in OBS, no restart needed. **Controller / route / `.env` changes need a supervisord restart** (`sudo supervisorctl restart obs-webapp`) — only then will the browser sources see the new behavior on next Refresh cache. CSS and JS under `webapp/public/` are pure static files; no restart needed, just Refresh cache. **Detecting whether OBS is running** — the Flatpak's inner binary is just `obs`, not `flatpak run com.obsproject.Studio`. Use: ```bash diff --git a/archived/README.md b/archived/README.md new file mode 100644 index 0000000..999fc9b --- /dev/null +++ b/archived/README.md @@ -0,0 +1,52 @@ +# archived/ + +Pre-`webapp/` artefacts retained for reference and rollback. + +## scenes/ +The seven hand-authored HTML scene overlays that lived at the repo root +before the Laravel migration: + +- `landing/` — "PLEASE STAND BY" with telemetry rotator +- `loading/` — project-load terminal + countdown + manifest +- `game/` — game HUD with camera-frame OBS-WS sync +- `desktop/` — desktop HUD (camera + screen frames) +- `goodbye/` — sign-off terminal + "OFFLINE FOR" counter +- `music/` — legacy browser-side music daemon (HTML5 `