[Unit]
Description=Touch panel agent (Home Assistant MQTT control surface for Sway)
Documentation=file:///opt/touchpanel-agent
# A system unit, not a `systemctl --user` unit — see thinclient-agent.service's
# identical reasoning: this must be reachable over MQTT whether or not a graphical
# session is up, and must survive sway restarting. Session-scoped bits (SWAYSOCK,
# XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESS) are derived at call time in
# sway_control.SwayControl.session_env().
#
# Deliberately NOT After=network-online.target: the panel must boot to a usable
# session (Spotify/HA/browser) with the container host powered off.
After=network.target

[Service]
Type=simple
User=@KIOSK_USERNAME@
Group=@KIOSK_USERNAME@
WorkingDirectory=/opt/touchpanel-agent
Environment=PYTHONPATH=/opt/touchpanel-agent
Environment=PYTHONUNBUFFERED=1
EnvironmentFile=-/etc/touchpanel-agent/config.env
ExecStart=/usr/bin/python3 -m touchpanel_agent.main
Restart=always
RestartSec=5
# Sandboxing stops here on purpose: this unit's whole job is to spawn GUI child
# processes (Chromium, the Spotify flatpak, Firefox) that need the real /tmp, the
# user's home, and the session bus.
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
