[Unit]
Description=RustDesk
Requires=network.target
After=systemd-user-sessions.service

[Service]
Type=simple
ExecStart=/usr/bin/rustdesk --service
# kill --tray and --server both
ExecStop=pkill -f "rustdesk --"
# below two lines do not work, have to use above one line
#ExecStop=pkill -f "rustdesk --tray"
#ExecStop=pkill -f "rustdesk --server"
PIDFile=/run/rustdesk.pid
KillMode=mixed
TimeoutStopSec=30
User=root
LimitNOFILE=100000
Environment="PULSE_LATENCY_MSEC=60" "PIPEWIRE_LATENCY=1024/48000"

[Install]
WantedBy=multi-user.target
