The second most-asked question after How to Install Latest Kodi 17.1 Krypton on Raspberry Pi is “How to make Kodi Autostart when i boot my Raspberry Pi?”.
Most people have a dedicated Raspberry Pi sitting behind a TV to act as a media center, and so they don’t want the hassle of having to connect via SSH or wireless keyboard to start Kodi whenever the Raspberry Pi is rebooted for any reason.
There are a lot of answers and solutions to this question, while some solutions work, they are neither easy nor straight-forward and most probably you will have to try a lot of solutions to find one that’s working for you.
But now i found how to make this happen with only ONE command, this is possible because basically Raspbian is running LXDE window manger, and thanks to ArchWiki i found out how to autostart an application in a safe and easy way.
All you have to do is to login to your Raspberry Pi, open a terminal, and paste the below line:
echo "@kodi" >> ~/.config/lxsession/LXDE-pi/autostart
Basically we are instructing LXDE to run Kodi after launching the window manager, that’s it, as simple as that.
If you want to know more or make Kodi autostart for any and all users, you can read more at ArchWiki’s page about LXDE
This is perfect, thank you so much !
Thanks!
hi,
after doing this i get a black screen.
kodi is working, ( i can here the sound of the button selection) but the screen is totally black.
how do we cancel the autostart?
how do i go back to the desktop from kodi?
thank you.
When did you get the black screen? after Kodi started or after quitting it?
Anyway, to revert this modify the file at ~/.config/lxsession/LXDE-pi/autostart and remove the line you just appended.
works, thanks !! 🙂
Work perfectly, thanks
Works awesome!
Thanks, close to 2019 and the line of code is still working.
You are the man. Works perfectly fine.
in raspberry pi 4 put this command :
sudo nano ~/.config/lxsession/LXDE-pi/autostart
add the line:
@kodi
Black screen with a mouse cursor?
HERE’S THE REASON, AND THE FIX:
According to https://wiki.archlinux.org/index.php/LXDE#Autostart, if there is a local file (~/.config/lxsession/LXDE-pi/autostart) and a global file, (/etc/xdg/lxsession/LXDE/autostart) LXsession only executes the local file as of v0.4.9 (I presume, of LXDE.)
So, [echo “@kodi” >> ~/.config/lxsession/LXDE-pi/autostart] creates a new autostart, which causes the global one not to run, and the commands in THAT file are NOT run. You get no desktop on which Kodi should display.
>>> DO THIS INSTEAD <<> ~/.config/lxsession/LXDE-pi/autostart
<<>>
/etc/xdg/lxsession/LXDE $ more ~/.config/lxsession/LXDE-pi/autostart
File contents should look like this.
@lxpanel –profile LXDE-pi
@pcmanfm –desktop –profile LXDE-pi
@xscreensaver -no-splash
point-rpi
@kodi
<<>>
On my Raspberry Pi 4, the line, ‘@kodi’ crashed. So I had to use
@/usr/bin/kodi-rpi4
instead.
Ain’t Linux grand?
I don’t know what evil the formatting system did to my preceding post, but the commands needed were:
cp -f /etc/xdg/lxsession/LXDE-pi/autostart ~/.config/lxsession/LXDE-pi/
followed by:
echo “@kodi” >> ~/.config/lxsession/LXDE-pi/autostart
Your help in correcting this would be greatly appreciated.