[Unit]
Description=Lock desktop session after inactivity
Requires=xorg.target
After=xorg.target

[Service]
ExecStart=/usr/bin/xautolock -time 5 -locker 'dm-tool switch-to-greeter' -detectsleep -resetsaver -secure
KillMode=process
Restart=on-failure

[Install]
WantedBy=graphical-session.target
