nano /usr/lib/systemd/user/sunshine.service
[Unit]
Description=Self-hosted game stream host for Moonlight
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
ExecStart=/usr/bin/sunshine
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=graphical-session.target
systemctl --user enable sunshine
j@dev:~$ cat .config/systemd/user/sunshine.service.d/override.conf
[Unit]
After=graphical-session.target
BindsTo=graphical-session.target
[Service]
# Wait for WAYLAND_DISPLAY to be available, then import it
ExecStartPre=/bin/bash -c 'for i in $(seq 1 30); do systemctl --user show-environment | grep -q "^WAYLAND_DISPLAY=" && break; sleep 1; done'
ExecStartPre=/bin/bash -c 'systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP'
[Install]
WantedBy=graphical-session.target