[Unit] Description=mpv persistent player (DRM/HDMI output, JSON IPC) # 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 [Service] Type=simple User=${MEDIAPI_USER} SupplementaryGroups=video render RuntimeDirectory=mediapi RuntimeDirectoryMode=0770 # 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 Restart=on-failure RestartSec=2 [Install] WantedBy=multi-user.target