[Unit]
Description=Dune Weaver Touch Interface
After=multi-user.target network-online.target
Wants=network-online.target
# Wait for DRM/KMS devices to be ready
After=systemd-udev-settle.service
Wants=systemd-udev-settle.service

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/dune-weaver-touch
Environment=QT_QPA_PLATFORM=eglfs
Environment=QT_QPA_EGLFS_ALWAYS_SET_MODE=1
Environment=QT_QPA_EGLFS_HIDECURSOR=1
Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms
Environment=QT_QPA_EGLFS_KMS_ATOMIC=1
# CPU isolation: Pin touch app to core 3, lower priority to prevent starving motion backend
# Backend runs pinned to cores 0-2 for serial I/O timing reliability
Nice=10
CPUQuota=25%
ExecStart=/usr/bin/taskset -c 3 /home/pi/dune-weaver-touch/venv/bin/python /home/pi/dune-weaver-touch/main.py
Restart=always
RestartSec=10
StartLimitInterval=200
StartLimitBurst=5

[Install]
WantedBy=multi-user.target
