The official kodi wiki suggests using lightdm with the autologin enabled in order to autostart kodi. But there is a problem with this approach: If kodi crashes (which it frequently does), you are greeted with the login screen instead of having kodi restart.
What you would need is a kiosk mode for lightdm - which is awefully heavy in configuration - at least in comparison with nodm:
- Simply
apt install nodm
- then edit
/etc/default/nodm
and changeNODM_USER=root
forNODM_USER=kodi
(or whatever kodi user you have)
Then, enable autostarting for the user:
$ mkdir -p ~/.config/autostart && ln -s /usr/bin/kodi ~/.config/autostart