12

I've got Kodi 17 Krypton and would like to start the app automatically when the Raspberry Pi boots.

How can I do this?

7

7 Answers 7

12

Aside from the answers already provided by others, you could also utilise the crontab to do this fairly easily provided that you have already disabled starting Raspbian GUI on startup via raspi-config.

sudo crontab -e

Then add the following line:

@reboot kodi --standalone

Thorough description on my blog post.

4
  • 1
    This makes my system freeze at startup
    – faceclean
    Oct 31, 2019 at 19:16
  • @ablmf Try running Kodi directly to see if that freezes. I remember trying out Raspbian Buster where Kodi ran very slowly. raspberrypi.org/forums/viewtopic.php?t=244069. I reverted back to Stretch. Nov 2, 2019 at 4:13
  • Works like a charm
    – Yair Daon
    Nov 2, 2019 at 7:43
  • 2
    just one important thing to add to this, if you run sudo crontab -e you will be editing root's crontab, and thus kodi will run as root. You might wanna run crontab -e instead, to run as a normal user. Also, if you were running kodi as a normal user before, you will not have any of your configuration by launching kodi as root.
    – jpnadas
    Dec 22, 2019 at 10:46
8

If you are running Raspbian 10 (based on Debian Buster), then the proper way to add it is to add @kodi to the file ~/.config/lxsession/LXDE-pi/autostart which will automatically start it only for your user. If you add it to /etc/xdg/lxsession/LXDE-pi/autostart then it will affect all users.

The Kodi Wiki suggests that you run the following:

sudo sed -i "1i @kodi" /etc/xdg/lxsession/LXDE-pi/autostart

The sed -i "1i @kodi" part simply puts the @kodi line at the top of the file. Putting it at the top of the file may prevent the desktop from showing up for a brief second. Exiting Kodi will bring you to the desktop in either case.

You can find out which Raspbian version you are running with:

$ cat /etc/issue
Raspbian GNU/Linux 10 \n \l
0
4

For Raspbian GNU/Linux 9 (Stretch), the following is used to autostart kodi at boot:

  1. Edit file /etc/default/kodi and set

    ENABLED=1

  2. Unmask and enable the kodi systemd service:

    sudo systemctl unmask kodi.service

    sudo systemctl enable kodi.service

4
  • 2
    what if kodi.service does not exist in the first place? Dec 11, 2017 at 20:29
  • 1
    I have tested only on raspbian which provices a kodi deb package with the "kodi.service" convenience. If your installation does not have such an init script, maybe you can create one as described in the kodi wiki: kodi.wiki/view/Archive:HOW-TO:Autostart_Kodi_for_Linux
    – Verve
    Dec 19, 2017 at 18:24
  • 1
    no kodi file in /etc/default/ on mine (raspbian 9.6 stretch)
    – austin
    Jan 16, 2019 at 22:09
  • 2
    kodi.service is no longer shipped with the kodi apt package (change committed 2018-04-28). The recommendation from that commit is to use the LXDE autostart instead, as other answers suggest.
    – Joel Purra
    Sep 27, 2020 at 10:42
3

In my case to append "kodi &" at the end of "/etc/rc.local" does not work.

Neither the option of "ENABLED=1" into "/etc/default/kodi", because the file and the startup scripts does not exist.

I have tried to append the following instead that is working for me:

sudo -b -u pi kodi

By the way, if somebody knows how to set up it using a service, and respawn the service when it shut down for any reason, it could be very cool.

I am using raspbian as linux distribution.

0

Don't take this the wrong way but would OpenELEC be more suitable? If not, add it to /etc/rc.local just above the last line.

Kodi &

Something like that but you may need the full path.

0

To have it start automatically you just have to do

sudo systemctl enable kodi

and later if you want to remove it

sudo systemctl disable kodi
1
-1

Start by running

crontab -e

Then run

@reboot sudo -b -u pi kodi
1
  • Could you please add some sort of explanation to your answer?
    – Darth Vader
    Nov 11, 2018 at 9:33

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