# KODI Installation version 20.1 Nexus on Debian 11 (Bullseye)

# Kodi is a multi-platform home-theater PC (HTPC) application.
# official repository: https://github.com/xbmc/xbmc
# website: http://kodi.tv/
# update all pkgs
$ sudo apt update
# if need run upgrade
$ sudo apt upgrade
# all pkgs must be up to date before going further
# edit source list to add testing repo
$ sudo nano /etc/apt/sources.list
# add the line below at end
deb http://deb.debian.org/debian testing main non-free contrib
# CTRL+X and Y to SAVE
# get testing packages list
$ sudo apt update
DO NOT UPGRADE
# install kodi 20.1
cd ~/Downloads
# AMD64
# download packages
$ wget -O kodi_20.1+dfsg-1_amd64.deb http://ftp.us.debian.org/debian/pool/main/k/kodi/kodi_20.1+dfsg-1_amd64.deb
# in case of dependencies error, download and install all pkgs
$ for x in {'kodi-repository-kodi_20.1+dfsg-1_all.deb','kodi-data_20.1+dfsg-1_all.deb','kodi-bin_20.1+dfsg-1_amd64.deb','kodi_20.1+dfsg-1_amd64.deb'}; do wget $x http://ftp.us.debian.org/debian/pool/main/k/kodi/$x; done
# install Kodi 20.1 manually
$ sudo apt install ./kodi-data_20.1+dfsg-1_all.deb ./kodi-bin_20.1+dfsg-1_amd64.deb ./kodi_20.1+dfsg-1_amd64.deb ./kodi-repository-kodi_20.1+dfsg-1_all.deb
# or
$ sudo apt install kodi
# ARM64 Raspberry PI 4
$ for x in {'kodi-repository-kodi_20.1+dfsg-1_all.deb','kodi-data_20.1+dfsg-1_all.deb','kodi-bin_20.1+dfsg-1_arm64.deb','kodi_20.1+dfsg-1_arm64.deb'}; do wget $x http://ftp.us.debian.org/debian/pool/main/k/kodi/$x; done
# install Kodi 20.1 manually
$ sudo apt install ./kodi-data_20.1+dfsg-1_all.deb ./kodi-bin_20.1+dfsg-1_arm64.deb ./kodi_20.1+dfsg-1_arm64.deb ./kodi-repository-kodi_20.1+dfsg-1_all.deb
# or
$ sudo apt install kodi
# install Kodi PVR IPTV Simple
$ $ sudo apt install kodi-pvr-iptvsimple
# be sure to install official repo
$ $ sudo apt install kodi-repository-kodi
# add current user to all needed groups
$ sudo usermod -aG adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input $USER
# edit source list to comment testing repo
$ sudo nano /etc/apt/sources.list
# comment testing repo
#deb http://deb.debian.org/debian testing main non-free contrib
# CTRL+X and Y to SAVE
# get main packages list
$ sudo apt update
# enable power policy for pi user
$ sudo nano /etc/polkit-1/localauthority/50-local.d/50-kodi.pkla
[Allow consolekit] Identity=unix-group:plugdev Action=org.freedesktop.upower.suspend;org.freedesktop.consolekit.system.* #Action=org.freedesktop.consolekit* ResultAny=yes ResultInactive=no ResultActive=yes [Allow login1] Identity=unix-group:plugdev Action=org.freedesktop.login1* ResultAny=yes ResultInactive=no ResultActive=yes [Allow Upower] Identity=unix-group:plugdev Action=org.freedesktop.upower.suspend ResultAny=yes ResultInactive=no ResultActive=yes
# CTRL + X the Y to SAVE
# create kodi service
$ sudo nano /lib/systemd/system/kodi.service
[Unit] Description = Kodi Media Center After = remote-fs.target network-online.target Wants = network-online.target [Service] User = pi Group = pi Type = simple ExecStart = /usr/bin/kodi-standalone Restart = on-abort RestartSec = 5 [Install] WantedBy = multi-user.target
# CTRL + X the Y to SAVE
$ sudo systemctl daemon-reload
$ sudo systemctl enable kodi
$ sudo systemctl start kodi
$ sudo systemctl status kodi
# add kodi smb share points at the end of conf
$ sudo nano /etc/samba/smb.conf
[kodi] path = /home/pi/.kodi read only = no public = yes writable = yes browseable = yes guest ok = yes create mask = 0777 directory mask = 0755 force user = pi [userdata] path = /home/pi/.kodi/userdata read only = no public = yes writable = yes browseable = yes guest ok = yes create mask = 0777 directory mask = 0755 force user = pi
# CTRL + X the Y to SAVE
$ sudo systemctl restart smbd
$ sudo reboot
# Adding media source to Kodi
# IMPORTANT NOTICE for Windows network SMB share in Kodi 20
# make sure to configure your NAS with shared folders using SMB v2 or v3 and with
# access to everyone (no user/pass)
# setup KODI SMB service with minimum version SMBv2 and maximum SMBv3
# browse the network from a PC and check if you have a full access to shared
# folders without needing to enter your credential
# then in Kodi create your movies, TV shows, etc. source points (i.e. //MYSERVER/Video ) with
# a dummy username and password (like username: srcmedia and paswd: srckodi)
# OPTIONAL: create Video and TV Shows folders if you store the media on the server (not recommended)
$ cd ~/
$ mkdir Video
$ mkdir "TV Shows"
# setup HDMI CEC
# on raspberry PI 4 HDMI CEC is already managed,
# however some keys of remote control must be adjusted like the back and contextual menu key.
# use the Keymap Editor addon (already installed) to make your changes in >global>navigation.
# on amd64 platform
# do not forget to add the Pulse Heigh CEC adapter ( https://www.pulse-eight.com ) to be able to use the TV remote control even with the Intel NUC which have a poor CEC implementation (you may need to deactivated internal IR Receiver and HDMI CEC in Intel NUC Bios).
# install rc6 mce IR remote control with Kodi 20
# by default Kodi manages the RC6 MCE remote control if your usb dongle is installed or the built in extended IR receiver is set in your bios
# unfortunately some essential buttons of the remote control do not work like BACK (KEY_BACK) and OK (KEY_OK) for example. Read the instructions below to fix it.
# open SSH session
# install ir-keytable
$ sudo apt install ir-keytable
# check if remote control is recognized
$ sudo ir-keytable
# result for usb dongle (mceusb)
Found /sys/class/rc/rc0/ with: Name: Media Center Ed. eHome Infrared Remote Transceiver (147a:e03e) Driver: mceusb Default keymap: rc-rc6-mce Input device: /dev/input/event6 LIRC device: /dev/lirc0 Attached BPF protocols: Operation not supported Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm Enabled kernel protocols: lirc rc-6 bus: 3, vendor/product: 147a:e03e, version: 0x1201 Repeat delay = 500 ms, repeat period = 125 ms
# example with build IR (cir)
Found /sys/class/rc/rc0/ with: Name: ITE8708 CIR transceiver Driver: ite-cir Default keymap: rc-rc6-mce Input device: /dev/input/event4 LIRC device: /dev/lirc0 Attached BPF protocols: Operation not supported Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm Enabled kernel protocols: lirc rc-6 bus: 25, vendor/product: 1283:0000, version: 0x0000 Repeat delay = 500 ms, repeat period = 125 ms
# Important Info are:
system device: rc0 (Found /sys/class/rc/rc0/) driver: mceusb or ite-cir protocol: rc-6
# copy the rc6 mce keymap rc6_mce.toml from /lib/udev/rc_keymaps/ to /etc/rc_keymaps/
$ sudo cp /lib/udev/rc_keymaps/rc6_mce.toml /etc/rc_keymaps/
# edit the keymap to fix it
$ sudo nano /etc/rc_keymaps/rc6_mce.toml
# replace entries 0x800f0412, 0x800f0413, 0x800f0418, 0x800f0422 and 0x800f0423 with:
. . 0x800f0412 = "KEY_PAGEUP" 0x800f0413 = "KEY_PAGEDOWN" . 0x800f0418 = "KEY_PLAY" . . 0x800f0422 = "KEY_ENTER" 0x800f0423 = "KEY_BACK"
# CTRL+X then Y to save
# edit /etc/rc_maps.cfg to add our custom keymap for mceusb and ite-cir driver
$ sudo nano /etc/rc_maps.cfg
# add these lines at end
mceusb * /etc/rc_keymaps/rc6_mce.toml ite-cir * /etc/rc_keymaps/rc6_mce.toml
# CTRL+X then Y to save
# now we are going to create a service to load our keymap at startup
$ sudo nano /etc/systemd/system/rc6mce-ir-keytable.service
# rc-6 protocol and sys/class/rc rc0 is reported and obviously the path to our keymap
[Unit] Description=RC6 MCE Keymap Fix After=network.service kodi.service [Service] Type=oneshot ExecStart=/usr/bin/ir-keytable -c -p rc-6 --write=/etc/rc_keymaps/rc6_mce.toml --sysdev=rc0 [Install] WantedBy=default.target
# CTRL+X then Y to save
# activate the service
$ sudo systemctl enable rc6mce-ir-keytable.service
# start service
$ sudo systemctl start rc6mce-ir-keytable.service
# now the pause, back and OK buttons work and to get info select the item on Kodi and do a long press on OK
# reboot
$ sudo reboot
# to test your remote control or get the correct scancode
$ sudo ir-keytable -t
# UNINSTALL KODI SERVICES
# if for some reason you no longer need the Home Theater service and want to keep the server for the audio system only (in short using it as the MusicLounge server) do the following
$ sudo systemctl stop kodi
$ sudo systemctl disable kodi
$ sudo reboot
# remove kodi user data and configuration files
$ cd ~/
$ sudo rm -r .kodi
# Backup / Restore Kodi Data
# backup
$ cd ~/
$ tar cvzf ~/Downloads/"kodi_backup-$(date +'%m-%d-%y').tar.gz" --exclude=.kodi/temp .kodi
# restore
$ cd ~/
$ sudo systemctl stop kodi
$ tar xzvf kodi_backup-xx-xx-xx.tar.gz
$ sudo systemctl start kodi
# Congrats! The audiophile server and the Kodi Home Theater is ready
# setup the Kodi SYSTEM > AUDIO > and choose the correct number of speakers
# activate the passthrough to take benefit of Dolby, DTS, trueHD, etc.