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?

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
Mario Serda
  • 133
  • 1
  • 1
  • 4
  • Already a question on this. It covers command line and GUI programs. https://raspberrypi.stackexchange.com/questions/8734/execute-script-on-start-up – pfl Jun 26 '17 at 09:40
  • Check out the link below to autostart kodi 17.5 on Raspbian Jessie and Stretch, be sure to check out the comment for the error solutions, lines 6 and 15 are incorrect in the readme. https://gist.github.com/Cyberek/33af1b92c071791a71aa8bccf87b8a3a – IsamAB Nov 12 '17 at 16:38
  • Direct link for correct approach on latest update (Raspbian Stretch & Kodi 17.5): https://gist.github.com/Cyberek/33af1b92c071791a71aa8bccf87b8a3a#gistcomment-2304207 (I found it via this link, so commenting for future searches) – Phil Sheard Feb 15 '18 at 08:48
  • I simply added @kodi in ~/.config/lxsession/LXDE-pi/autostart as instructed on https://www.makeuseof.com/tag/install-kodi-raspbian-media-center/ – 0xced Dec 22 '18 at 19:38
  • create the service! instructs here https://www.raspberrypi.org/forums/viewtopic.php?p=1207376 – austin Jan 16 '19 at 22:48
  • This command is all you need. "echo "@kodi" >> ~/.config/lxsession/LXDE-pi/autostart" as per https://mtantawy.com/how-to-autostart-kodi-on-raspberry-pi-using-only-one-command/ . It worked for me. – David Okwii Jan 27 '19 at 16:17
  • Using systemd (with big advantage of restarting Kodi in case of crashes) https://github.com/brunetton/kodi_systemd/blob/main/kodi.service – brunetton Feb 19 '22 at 23:54

7 Answers7

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.

Leow Kah Man
  • 233
  • 2
  • 4
  • 1
    This makes my system freeze at startup – NonalcoholicBeer Oct 31 '19 at 19:16
  • @ablmf Try running Kodi directly to see if that freezes. I remember trying out Raspbian Buster where Kodi ran very slowly. https://www.raspberrypi.org/forums/viewtopic.php?t=244069. I reverted back to Stretch. – Leow Kah Man Nov 02 '19 at 04:13
  • Works like a charm – Yair Daon Nov 02 '19 at 07: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 '19 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
stefansundin
  • 201
  • 1
  • 3
  • 3
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

Verve
  • 141
  • 4
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.

Andy Anderson
  • 638
  • 1
  • 4
  • 11
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
Edoardo
  • 158
  • 1
  • 5
-1

Start by running

crontab -e

Then run

@reboot sudo -b -u pi kodi
Darth Vader
  • 4,206
  • 24
  • 45
  • 69
Steven
  • 1