[Unit]
Description=MageDok 7" Display Setup and Auto-Launch
Documentation=https://gitea.vayrette.com/seb/saltylab-firmware/issues/369
After=network-online.target
Wants=network-online.target
ConditionPathExists=/dev/pts/0

[Service]
Type=oneshot
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/env bash -c 'source /opt/ros/jazzy/setup.bash && ros2 launch saltybot_bringup magedok_display.launch.py'
ExecStartPost=/usr/bin/env bash -c 'DISPLAY=:0 /usr/bin/startx -- :0 vt7 -nolisten tcp 2>/dev/null &'

StandardOutput=journal
StandardError=journal
SyslogIdentifier=magedok-display
User=orin
Group=orin
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/orin/.Xauthority"

Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
