1

On my rpi4b I have installed Kodi, and added kodi.service to /etc/systemd/system:

root@raspberrypi:/etc/systemd/system# cat kodi.service 
[Unit]
Description = Kodi media center
After=remote-fs.target systemd-user-sessions.service network-online.target nss-lookup.target sound.target bluetooth.target polkit.service upower.service mysqld.service
Wants=network-online.target polkit.service upower.service

[Service]
User=root
Group=root
ExecStart=/usr/bin/xinit /usr/bin/kodi --standalone
Restart=always
StandartInput=tty
StandardOutput=journal

[Install]
WantedBy=graphical.target

When I reboot rpi4, I see login prompt (no GUI here, only CLI). I can login, everything works as expected.

I connect via ssh, and enable kodi at startup with systemctl enable kodi, this command does not print anything and exits with code 0. Then, type systemctl start kodi -> kodi starts, everything works as expected.

Since I enabled kodi service, I expect it to start after reboot, but what I actually see is login prompt (no GUI).

This is what I see when type systemctl status kodi after login:

● kodi.service - Kodi media center
   Loaded: loaded (/etc/systemd/system/kodi.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

What do I do wrong?

3 Answers 3

1

If you only care to have a kodi running when the raspberry starts, instead of make a service you could use the simpler 'crontab' method mentioned in the wiki

Edit the crontab:

crontab -e

Add:

@reboot kodi --standalone

just that.

Note that if you use the root crontab (ie: sudo crontab -e) kodi will get his settings fron the root user, and will be a different config that you see when you start it from the pi normal user.

4

There is a typo in your Unit file. Please correct StandartInput=tty to StandardInput=tty. Then I do not understand why do you use this setting. According to man systemd.exec it is said:

If tty is selected, standard input is connected to a TTY (as configured by TTYPath=, see below) and the executed process becomes the controlling process of the terminal. If the terminal is already being controlled by another process, the executed process waits until the current controlling process releases the terminal.

I do not understand this completely in your context but there are strong indicators that this could make your problems. Try without setting StandardInput=tty.

2

I've made a repo to share my systemd unit that works for me so far:

https://github.com/brunetton/kodi_systemd/

This could probably be improved, to cover most cases, but this works. It have the bug advantage over crontab to watch process and restart kodi when it crashes (thanks to the Restart=always directive)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.