SmartestHome/hosts/steam-tv-box/agent/steamtv-agent.service

40 lines
1.7 KiB
INI

[Unit]
Description=Steam TV box agent (Home Assistant MQTT control surface for Sway)
Documentation=file:///opt/steamtv-agent
# A system unit rather than a `systemctl --user` unit: the agent has to be reachable
# over MQTT whether or not a graphical session is up, and it has to survive sway
# restarting (a user unit bound to graphical-session.target would go down with it).
# The session-scoped bits it needs — SWAYSOCK, XDG_RUNTIME_DIR,
# DBUS_SESSION_BUS_ADDRESS — are derived at call time from the kiosk user's runtime
# directory in sway_control.SwayControl.session_env(), which also means they are
# re-resolved after every sway restart instead of being frozen at unit start.
#
# Deliberately NOT After=network-online.target: this box must boot to Big Picture and
# play a game with the container host powered off, same rule as the thin client's
# Phase 11.10.
After=network.target
[Service]
Type=simple
User=@KIOSK_USERNAME@
Group=@KIOSK_USERNAME@
WorkingDirectory=/opt/steamtv-agent
Environment=PYTHONPATH=/opt/steamtv-agent
Environment=PYTHONUNBUFFERED=1
EnvironmentFile=-/etc/steamtv-agent/config.env
ExecStart=/usr/bin/python3 -m steamtv_agent.main
Restart=always
RestartSec=5
# Deliberately gentle on shutdown, and more so than the other agents: this process is
# the parent of nothing important, but `media-session stop` reaches Firefox and Spotify,
# both of which persist state on exit.
KillMode=mixed
TimeoutStopSec=20
# Sandboxing stops here on purpose: this unit's whole job is to spawn GUI child
# processes (Firefox, the Spotify and Prism flatpaks, Steam) that need the real /tmp,
# the user's home, and the session bus.
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target