2026-07-06 01:45:57 +00:00
|
|
|
[Unit]
|
|
|
|
|
Description=mpv persistent player (DRM/HDMI output, JSON IPC)
|
2026-07-06 02:19:52 +00:00
|
|
|
# Wait until udev has settled so the DRM/HDMI devices (/dev/dri/*) exist
|
|
|
|
|
# before mpv tries to grab the display. Without this, a cold-boot race can
|
|
|
|
|
# leave mpv running but never rendering to HDMI (you see the console instead),
|
|
|
|
|
# even though the exact same command works when run by hand later.
|
|
|
|
|
After=local-fs.target systemd-udev-settle.service
|
|
|
|
|
Wants=systemd-udev-settle.service
|
2026-07-06 01:45:57 +00:00
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
Type=simple
|
Extract config into .env; add deploy.sh with overlay guard + rollback
- Move user-specific config (login, media roots, port, AP ssid/psk, service
user) into a gitignored .env; add .env.example template.
- config.py reads .env at startup via a tiny zero-dependency parser (works for
both `uv run` and systemd), and fails loudly if required vars are unset.
- load_secret_key falls back to an ephemeral key on a read-only filesystem
instead of crashing.
- systemd units become .template files; deploy.sh renders them with the
.env-derived user/paths.
- deploy.sh: refuses to run on a read-only overlay, git pull --ff-only,
uv sync, ensure secret key, re-apply the AP from .env, install units,
restart, health-check with automatic rollback to the previous commit.
- Scrub literal credentials/ssid out of the README; document .env + deploy.sh.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 02:06:47 +00:00
|
|
|
User=${MEDIAPI_USER}
|
2026-07-06 01:45:57 +00:00
|
|
|
SupplementaryGroups=video render
|
|
|
|
|
RuntimeDirectory=mediapi
|
|
|
|
|
RuntimeDirectoryMode=0770
|
2026-07-07 00:33:46 +00:00
|
|
|
# start-mpv.py enumerates the connected HDMI connectors and launches one mpv
|
|
|
|
|
# per screen: the primary carries audio + the app's IPC socket, and each extra
|
|
|
|
|
# screen gets a video-only mirror mpv on its own socket. If any mpv dies the
|
|
|
|
|
# launcher exits non-zero and systemd restarts us, which re-enumerates the
|
|
|
|
|
# displays. See the script header for the full rationale.
|
|
|
|
|
ExecStart=/usr/bin/python3 ${PROJECT_DIR}/scripts/start-mpv.py
|
2026-07-06 01:45:57 +00:00
|
|
|
Restart=on-failure
|
|
|
|
|
RestartSec=2
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|