I took @
graysky 's Arch systemd-units and @
fritsch 's original instructions as templates for my Kodi situation (running appliance-like on a Ubuntu 21.04 server) and came up with the following systemd unit which seems to work at the moment:
json:
[Unit]
Description=Kodi standalone
After=remote-fs.target systemd-user-sessions.service network-online.target nss-lookup.target
After=sound.target polkit.service upower.service
Wants=network-online.target polkit.service upower.service
Wants=emby.service tvheadend.service
[email protected]
[Service]
User=kodi
Group=users
PAMName=login
TTYPath=/dev/tty1
StandardInput=tty
StandardOutput=journal
TimeoutStopSec=30sec
Restart=on-abort
#GBM
Environment=WINDOWING=gbm
ExecStartPre=/usr/bin/proptest -M i915 -D /dev/dri/card0 109 connector 97 1
ExecStart=/usr/bin/kodi-standalone --windowing=gbm
SupplementaryGroups=input
#X11
#Environment=WINDOWING=x11
#ExecStart=/usr/bin/xinit /usr/bin/kodi-standalone -- :0 -quiet -nolisten tcp vt1
#ExecStartPost=/usr/bin/xrandr -display :0 --output DP-1 --set "Broadcast RGB" "Full"
#ExecStartPost=/usr/bin/xsetroot #000000
#ExecStartPost=/usr/bin/xset s off -dpms
#ExecStart=/usr/bin/xinit /usr/bin/kodi-standalone -- :0 -quiet -nolisten tcp vt1
ExecStop=/usr/bin/killall --user kodi --exact --wait kodi.bin
[Install]
Alias=display-manager.service
WantedBy=multi-user.target
Obviously, the way I switch to fullrange color is not very elegant, but the ouput of propset is not usable for parsing with my limited bash knowledge, so I hardcoded the command I need. (I still do not really understand the implications of full and limited range, but for me full-full-full looks good and sound better than limited-full-limited, which also seems to be a viable option ;-) .)
I also introduced a shorter stop timeout in order to kill a hung-up Kodi faster. I guess if the shutdown of Kodi takes longer than 30secs, something is wrong.
Moreover I use "monit" to keep the kodi service reliably running.
Maybe this is helpful for others...