HOW-TO:Autostart Kodi for Linux

From Official Kodi Wiki
Jump to navigation Jump to search

Any or all or any combination of these methods can be used to configure a Debian-based X Window System to boot directly to Kodi. This should work on any Linux using the X Window System, but these instructions are particular to Debian derivatives, such as Ubuntu. A server edition is best for running only Kodi, but this page assumes booting into a desktop OS, not a server distro. However, the instructions here can be used for a server distro with even less configuration than for a desktop. Experiment inside VirtualBox before you apply any of these to your system and make a backup.

Switch to root

su

or

sudo su

Create a Kodi user

To use Kodi full-screen, you only have to create a standard user.

adduser kodi

To remove the password use:

passwd -d kodi

Customize LightDM to autologin

You can utilize the ability to customize LightDM data manager by changing the builtin custom configuration file 50-myconfig.conf using nano or another text editor. If you have no DE or WM you can install lightdm, but should make sure to do a bit of research before you do. Most versions of Linux use LightDM, but many server versions do not. For Ubuntu Server with no DE, for example, installing lightdm is okay and necessary. Changing the behavior of LightDM is done using a custom 50-myconfig.conf configuration file.

To see if you have lightdm use which.

which lightdm

If not, install it with apt.

apt install lightdm

Create a custom configuration file called 50-myconfig.conf using nano or other CLI text editor.

nano /etc/lightdm/lightdm.conf.d/50-myconfig.conf

Inside this new file add the following text.

[SeatDefaults]
autologin-user=kodi

Configure Kodi to autostart

Configure Kodi to autostart.

mkdir -p ~/.config/autostart
ln -s /usr/bin/kodi ~/.config/autostart

This method of autostart requires a desktop environment or DE.

If Kodi is not installed at the standard path, find it using the which command.

which kodi

Disable / enable the login prompt

You can disable the graphical login prompt.

systemctl set-default multi-user.target

To enable it again use.

systemctl set-default graphical.target

Create custom Xsession script

Most systems utilize the client version of the X11 software Kodi standalone service requires.

Upgrade to the server versions of the X Window System.

apt install xauth xorg xinit xserver-xorg-core xserver-xorg xserver-common

Create a custom Xsession script with a text editor.

nano ~/.xinitrc

To run Kodi full-screen make sure the text reads:

#!/usr/bin/env bash
exec /usr/bin/x-window-manager &
/usr/bin/kodi -fs &

If you are not sure of the path of X Window Manager, use the which command.

which x-window-manager

Use sudo and the ~/.xinitrc file to configure ~/.xsession.

sudo -H -u kodi bash -c "ln -s ~/.xinitrc ~/.xsession"

You need to use sudo to run this command. If you do not have sudo, install it.

apt install sudo

Remember you can modify use and reuse the ~/.xinitrc file to configure ~/.xsession as often as you want. That is the purpose of the file. It does nothing on its own until you associate it with a user.

Xsession to boot to app / WM / DE

You can use any window manager or desktop enviroment with a custom Xsession script as long as it is intalled.

You do this by creating ~/.xinitrc script that contains the command to start the WM or DE.

For instance, if you are using FluxBox?

#!/usr/bin/env bash
exec fluxbox &
/usr/bin/kodi -fs &

The -fs option is full-screen.

To start Gnome with Kodi full-screen:

#!/usr/bin/env bash
exec gnome-session &
/usr/bin/kodi -fs &

Use the ~/.xinitrc file to configure ~/.xsession to create a custom login for any user, not just Kodi.

sudo -H -u [username] bash -c "ln -s ~/.xinitrc ~/.xsession"

You must reconfigure Xserver for any user that is not a privileged user to be able to start a custom Xsession.

dpkg-reconfigure xserver-xorg-legacy

or

dpkg-reconfigure xserver-xorg

Add a custom Grub entry

If you want to boot to the CLI and manually launch an app, WM or DE, add a custom grub entry.

The right way to add a custom grub entry is to copy the menu entry you want to change or duplicate.

Copy the default Grub configuration file and open it with a text editor on your desktop. If you use a text editor on the CLI, the text will be cut off by the window when copying and pasting.

cp /boot/grub/grub.cfg grub.cfg
gedit grub.cfg

Copy the menu entry and paste it into 40_custom with a text editor in the CLI.

nano /etc/grub.d/40_custom

Where the menu entry contains quiet splash change it to text instead.

You should also change the name of the entry!

I just appended mine with “CLI” for command line interface.

To update Grub:

update-grub

To launch a WM you can type its name. I use Enlightment 17 or Fluxbox. It must be installed.

fluxbox

You must have FluxBox installed. There are countless other window managers.

To launch a DE you enter the appropriate command. For Gnome desktop:

gnome-session

For KDE:

startkde

or

plasma-desktop

For XFCE:

startxfce4

For Mate:

mate-session

For LXDE:

startlxde

You can either manually launch your apps, boot right into them, or create an Xsession for each user. This is great when you want to create a Kodi user for running Kodi only, and for making sure you can still login to your DE with your regular user account. You can boot to any app full-screen this way, not just Kodi. You can create a custom Xsession script for any user, configured with any startup applications running in full-screen mode or normally.

By optionally creating a Grub menu entry, you can create a different Grub menu selection to boot only to the CLI and start an Xsession with a script or run commands manually.