Difference between revisions of "Kodi"

From ArchWiki
Jump to: navigation, search
(Installation: clarify that addons are disabled)
m (use user group)
 
(89 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[Category:Multimedia players]]
+
[[Category:Home theater]]
 
[[ja:Kodi]]
 
[[ja:Kodi]]
 
[[zh-hans:Kodi]]
 
[[zh-hans:Kodi]]
[https://kodi.tv/ Kodi] (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.  These can all be played directly from a CD/DVD, or from the hard-drive. Kodi can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. It can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the [http://kodi.wiki/?title=PVR Kodi wiki].
+
[https://kodi.tv/ Kodi] (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.  These can all be played directly from a CD/DVD, or from the hard-drive. Kodi can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. It can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the [https://kodi.wiki/view/PVR Kodi wiki].
  
 
== Installation ==
 
== Installation ==
[[Install]] the {{Pkg|kodi}} package. Be sure to install the optional dependencies listed by pacman that apply to your specific use-case. All of the official addons in the {{Grp|kodi-addons}} group are disabled by default and need to be enabled in Kodi's addon menu after installation.
 
  
{{Note|Users of Arch ARM should be aware that several different kodi packages with specific hardware support are available.}}
+
The official stable release can be [[install]]ed via the {{Pkg|kodi}} package. Alternatively, recent alpha, beta, or RC builds are available from {{AUR|kodi-pre-release}}. Be sure to review/install optional dependencies listed by pacman to enable additional functionality.
 +
 
 +
All of the official addons in the {{Grp|kodi-addons}} group are disabled by default and need to be enabled in Kodi's addon menu after installation.
  
 
== Running ==
 
== Running ==
Line 13: Line 14:
 
The {{Pkg|kodi}} package supplies two binaries for two different use cases:
 
The {{Pkg|kodi}} package supplies two binaries for two different use cases:
  
# {{ic|/usr/bin/kodi}} is meant to be run by any user on a on-demand basis.  Use it like any other program on the system.
+
# {{ic|/usr/bin/kodi}} is meant to be run by any user on an on-demand basis.  Use it like any other program on the system.
# {{ic|/usr/bin/kodi-standalone}} is meant to be run as the only graphical application, for example on an HTPC. See [[#Running standalone]] for more information.
+
# {{ic|/usr/bin/kodi-standalone}} is meant to be run as the only graphical application, for example on a [[wikipedia:Home_theater_PC|HTPC]]. See [[#Running standalone]] for more information.
  
 
== Running standalone ==
 
== Running standalone ==
  
Setting up the system and running the standalone binary is advantageous for several reasons:
+
Using standalone mode is advantageous for several reasons:
  
# An unprivileged user cannot access a shell by definition.
+
# The default {{ic|kodi}} user is unprivileged and cannot access a shell.
# Running without a full blown DE is lighter and more simplistic.
+
# When paired with a systemd unit (or equivalent, see below), this setup makes the box on which kodi is running more like an appliance.
# When paired with a systemd unit (or equivalent, see below), this make the box on which kodi is running more like an appliance and very robust.
 
  
There are several methods to it this described below.
 
 
{{Warning|Select '''only one''' of the methods listed below.}}
 
{{Warning|Select '''only one''' of the methods listed below.}}
  
==== Kodi-standalone-service ====
+
=== kodi-standalone service ===
The {{AUR|kodi-standalone-service}} package provides {{ic|kodi.service}} and automatically creates the unprivileged user to run Kodi in standalone mode.  Although the correct [[Xorg#Driver_installation|driver]] is an assumed dependency, no extra Xorg packages are needed. [[Start]] {{ic|kodi.service}} and [[enable]] it to run at boot time.  No additional configuration should be required for most users, however, if {{ic|kodi.service}} fails to start, see [[Xorg#Rootless Xorg (v1.16)]]{{Broken section link}}.
+
 
 +
The {{AUR|kodi-standalone-service}} package provides {{ic|kodi.service}} and automatically creates the unprivileged user to run Kodi in standalone mode.  Although the correct [[Xorg#Driver_installation|driver]] is an assumed dependency, no extra Xorg packages are needed.
 +
 
 +
[[Start]] {{ic|kodi.service}} and [[enable]] it to run at boot time.
  
 
{{Note|
 
{{Note|
* The kodi user is unprivileged meaning it cannot login (default shell is {{ic|/usr/bin/nologin}}).
+
* If {{ic|kodi.service}} fails to start, see [[Xorg#Rootless Xorg]].
* The home directory for the kodi user created is {{ic|/var/lib/kodi}} not {{ic|/home/kodi}}.
+
* The home directory for the created {{ic|kodi}} user is {{ic|/var/lib/kodi/}}.
 
}}
 
}}
  
{{Warning|Users of Arch ARM should not attempt to install this package as breakage will occur!}}
+
=== Xsession with LightDM ===
  
==== Xsession with LightDM ====
+
{{Note|
{{Note|This assumes that the user has created an kodi user named kodiuser on the system and that the following file is present as described.}}
+
* This assumes that a kodi user named {{ic|kodi}} is on the system and that the following file is present as described.
{{Note|1=lightdm does not pull in an X server as a required dependency, it is optional. The X server listed as an optional dependency (xephyr) does not work when run as root by lightdm.service ([https://bugs.archlinux.org/?string=52067 Bug to have optional dependency modified]) ([https://bugs.launchpad.net/lightdm/+bug/852577 Upstream Bug]). Install [[Xorg#Installation|xorg-server]].}}
+
* {{pkg|lightdm}} does not pull in an X server as a required dependency, it is optional. The X server listed as an optional dependency ({{Pkg|xorg-server-xephyr}}) does not work when run as root by {{ic|lightdm.service}} ({{Bug|52067}}, [https://bugs.launchpad.net/lightdm/+bug/852577 LightDM Bug 852577]). [[Xorg#Installation|Install xorg-server]].
 +
}}
  
 
To use LightDM with automatic login, see [[LightDM#Enabling autologin]] and [[LightDM#Enabling interactive passwordless login]]. ''Kodi'' includes {{ic|kodi.desktop}} as [[xsession]].
 
To use LightDM with automatic login, see [[LightDM#Enabling autologin]] and [[LightDM#Enabling interactive passwordless login]]. ''Kodi'' includes {{ic|kodi.desktop}} as [[xsession]].
Line 46: Line 49:
 
[Seat:seat0]
 
[Seat:seat0]
 
pam-service=lightdm-autologin
 
pam-service=lightdm-autologin
autologin-user=kodiuser
+
autologin-user=kodi
 
autologin-user-timeout=0
 
autologin-user-timeout=0
 
user-session=kodi
 
user-session=kodi
 
}}
 
}}
  
==== Socket activation ====
+
=== Socket activation ===
  
Socket activation can be used to start Kodi when the user starts a remote control app or on a connection to Kodi's html control port. Start listening with ''systemctl start kodi@user.socket'' (replace ''user'' with the user running Kodi to be started as).
+
Socket activation can be used to start Kodi when the user starts a remote control app or on a connection to Kodi's html control port. Start listening by [[starting]] {{ic|kodi@''user''.socket}} (replace ''user'' with the user running Kodi to be started as).
  
The {{AUR|kodi-standalone-socket-activation}} package provides {{ic|kodi@.service}} but not {{ic|kodi@.socket}}. Depending on the setup, one may want to change the port in ''kodi@.socket''. This can be done by manually using the following systemd files.
+
There are no packaged {{ic|kodi@.socket}} and {{ic|kodi@.socket}} files, one must create them manually. Depending on the setup, one can optionally change the port in {{ic|kodi@.socket}}.
  
{{hc|/etc/systemd/system/kodi@.service|
+
{{hc|/etc/systemd/system/kodi@.service|<nowiki>
<nowiki>[Unit]
+
# This fails if the user does not have an X session.
 +
[Unit]
 
Description=Launch Kodi on main display
 
Description=Launch Kodi on main display
 +
Conflicts=kodi.socket
  
 
[Service]
 
[Service]
Type=oneshot
+
Type=simple
 
Environment=DISPLAY=:0.0
 
Environment=DISPLAY=:0.0
 
Nice=-1
 
Nice=-1
 
ExecStart=/usr/bin/su %i /usr/bin/kodi
 
ExecStart=/usr/bin/su %i /usr/bin/kodi
ExecStartPost=/usr/bin/bash -c "sleep 15 && systemctl start kodi@%i.socket"
+
ExecStopPost=/usr/bin/systemctl --no-block start kodi@%i.socket
  
 
[Install]
 
[Install]
WantedBy=multi-user.target</nowiki>}}
+
WantedBy=multi-user.target
 +
</nowiki>}}
  
 
{{hc|/etc/systemd/system/kodi@.socket|
 
{{hc|/etc/systemd/system/kodi@.socket|
Line 83: Line 89:
  
 
[Install]
 
[Install]
WantedBy=sockets.target</nowiki>}}
+
WantedBy=sockets.target
 +
</nowiki>}}
 +
 
 +
=== Start from remote control with LIRC / irexec ===
  
==== Start from remote control with LIRC / irexec ====
 
 
Kodi can be configured to start via a key press.  Users will need {{AUR|kodi-standalone-service}} and {{Pkg|lirc}}.  This can be useful on setups running 24/7 and having kodi up on demand.
 
Kodi can be configured to start via a key press.  Users will need {{AUR|kodi-standalone-service}} and {{Pkg|lirc}}.  This can be useful on setups running 24/7 and having kodi up on demand.
  
Line 91: Line 99:
  
 
Generate the file {{ic|/var/lib/kodi/.lircrc}} with the following content:
 
Generate the file {{ic|/var/lib/kodi/.lircrc}} with the following content:
{{hc|/var/lib/kodi/.lircrc|
+
 
<nowiki>
+
{{hc|/var/lib/kodi/.lircrc|<nowiki>
 
begin
 
begin
 
prog = irexec
 
prog = irexec
Line 100: Line 108:
 
repeat = 0
 
repeat = 0
 
end
 
end
</nowiki>
+
</nowiki>}}
 +
 
 +
Adopt {{ic|button}} to whatever button on the remote is to start Kodi. One can use ''irw'' (see [[LIRC#Usage]]) to find out the correct values for {{ic|remote}} and {{ic|button}}.
 +
 
 +
Create a [[Systemd#Drop-in files|drop-in]] for {{ic|kodi.service}}:
 +
 
 +
{{hc|/etc/systemd/system/kodi.service.d/lirc.conf|2=
 +
[Service]
 +
ExecStart =
 +
ExecStart = /usr/bin/irexec
 
}}
 
}}
  
Adopt {{ic|button}} to whatever button on the remote is to start Kodi.  One can use ''irw'' (see [[LIRC#Usage]]) to find out the correct values for {{ic|remote}} and {{ic|button}}.
+
[[Start]] {{ic|kodi.service}} and [[enable]] it to run at boot time.
 +
 
 +
== Using a remote control ==
 +
 
 +
As Kodi is geared toward being a remote-controlled media center via an official app, physical remote control, or USB/bluetooth keyboard/mouse.
  
Next copy {{ic|kodi.service}} from {{ic|/usr/lib/systemd/system/}} to {{ic|/etc/systemd/system/}} and change the line
+
=== Using the Android or iOS app ===
ExecStart = /usr/bin/kodi-standalone -l /run/lirc/lircd
+
 
to
+
Both Android and iOS users can use the official app (currently free of charge) to control kodi once it is correctly setup to do so.  Steps to configure both Kodi and the app are detailed on the [https://kodi.wiki/view/Official_Kodi_Remote Official Kodi Remote] page.
ExecStart = /usr/bin/irexec
+
 
 +
=== Using a physical remote control ===
 +
 
 +
Any PC with a supported IR receiver/remote, can use [[LIRC]] or even kernel supported modules to drive it.  Configuring specific remotes with lirc is covered on the [[LIRC]] article.
 +
 
 +
To work properly with Kodi, a file that maps the lirc events to Kodi keypresses is needed.  Create an [[Wikipedia:XML|XML]] file at {{ic|~/.kodi/userdata/Lircmap.xml}} (note the capital 'L').  
 +
 
 +
{{Note|Users running Kodi started with {{AUR|kodi-standalone-service}} will find the {{ic|kodi}} user's home ({{ic|~}}) under {{ic|/var/lib/kodi/}} and should substitute this in for the shortcut above.  Also make sure that if creating this file as the root user, it gets proper [[File permissions and attributes#Changing ownership|ownership]] as {{ic|kodi:kodi}} when finished.}}
 +
 
 +
{{ic|Lircmap.xml}} format is as follows:
 +
 
 +
{{bc|1=
 +
<lircmap>
 +
  <remote device="devicename">
 +
      <XBMC_button>LIRC_button</XBMC_button>
 +
      ...
 +
  </remote>
 +
</lircmap>
 +
}}
 +
 
 +
* '''Device Name''' is whatever LIRC calls the remote. This is set using the '''Name''' directive in lircd.conf and can be viewed by running {{ic|irw}} and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
 +
* '''XBMC_button''' is the name of the button as defined in [https://kodi.wiki/view/Keymap keymap.xml].
 +
* '''LIRC_button''' is the name as defined in {{ic|lircd.conf}}. If {{ic|lircd.conf}} was autogenerated using {{ic|irrecord}}, these are the names selected for the buttons. Refer back to [[LIRC]] for more information.
 +
* A very thorough [https://kodi.wiki/view/LIRC LIRC] page hosted on the Kodi Wiki should be consulted for more help and information on this subject as this is out of scope of this article.
 +
 
 +
=== HDMI-CEC ===
 +
 
 +
With a supported [https://www.pulse-eight.com/p/104/usb-hdmi-cec-adapter USB-CEC adapter], Kodi can be used to automatically turn on and off the TV and other home theater equipment. Volume control from Kodi can be sent to a supported amplifier, one can manage DVD or Blu-Ray players from inside Kodi, and redirect the active source on the TV to whichever equipment needs it, all from one remote control. For more information see the [https://kodi.wiki/view/CEC official Kodi wiki page on CEC] and [http://libcec.pulse-eight.com/faq libCEC FAQ].
 +
 
 +
Install {{Pkg|libcec}}.
 +
 
 +
{{Expansion|Add reference for the need to add users to these groups.}}
 +
 
 +
When connected, the USB-CEC's {{ic|/dev}} entry (usually {{ic|/dev/ttyACM*}}) will default to being owned by the {{ic|uucp}} group, so in order to use the device the user running Kodi needs to belong to that group. The user also needs to belong to the {{ic|lock}} group, otherwise Kodi will be unable to connect to the device. See [[Users and groups#Group management]] for instructions on how to add users to groups.
 +
 
 +
* Add all users that will use Kodi to the {{ic|uucp}} and {{ic|lock}} [[user group]]s.
 +
* If [[#Running standalone|running kodi-standalone]], add the user {{ic|kodi}} to the {{ic|uucp}} and {{ic|lock}} [[user group]]s.
 +
 
 +
{{Note|Trying to use the USB-CEC without belonging to above groups may lead to problems, including Kodi crashes, so make sure the correct user belongs to both groups.}}
 +
 
 +
== Sharing media and a centralized database across multiple nodes ==
  
[[Start]] {{ic|kodi.service}} and [[enable]] it to run at boot time.
+
If multiple PCs on the same network are running Kodi, they can be configured to share a single media library (video and music). The advantage of this is media and key metadata are stored in one place, and are shared/updated by all nodes on the network. For example, users of this setup can:
  
=== Sharing a database across multiple nodes ===
 
If multiple PCs on the same network are running Kodi, they can be configured to share a single media library (video and music).  The advantage of this is that key metadata are stored in one place, and are shared/updated by all nodes on the network.  For example, users of this setup can:
 
 
* Stop watching a movie or show in one room then finish watching it in another room automatically.
 
* Stop watching a movie or show in one room then finish watching it in another room automatically.
 
* Share watched and unwatched status for media on all nodes.
 
* Share watched and unwatched status for media on all nodes.
 
* Simplify the setup with only a single library to maintain.
 
* Simplify the setup with only a single library to maintain.
  
Several key things are needed for this to work:
+
As well, the media itself can be located in one space thus allowing a lighter footprint of client systems (ie no need for large HDD space).
 +
 
 +
Several things are needed for this to work:
 +
 
 
* Network exposed media (via protocols that Kodi can read, e.g. NFS or Samba).
 
* Network exposed media (via protocols that Kodi can read, e.g. NFS or Samba).
* A MySQL server (Arch uses {{pkg|mariadb}}).
+
* A [[MySQL]] server.
 +
 
 +
{{Warning|When sharing a database, ALL clients need to be on the same major version of Kodi due to versioned requirements of the database schema. Refer to [https://kodi.wiki/view/Databases#Database_Versions this] table for a list of database versions.}}
  
 
{{Note|The following guide is only an example of one configuration and is not meant to be limiting but illustrative.  Key steps are shown but a detailed discussion is not offered.}}
 
{{Note|The following guide is only an example of one configuration and is not meant to be limiting but illustrative.  Key steps are shown but a detailed discussion is not offered.}}
These assumptions are used for the guide, substitute to reflect your setup:
+
 
* The media is located under following mount points: {{ic|/mnt/tv-shows}} {{ic|/mnt/movies}} {{ic|/mnt/music}}.
+
These assumptions are used for the guide, substitute as needed:
 +
 
 +
* The media is located under following mount points: {{ic|/mnt/shows}} {{ic|/mnt/movies}} {{ic|/mnt/music}}.
 
* The network addresses of all nodes are within the 192.168.0.* subnet range.
 
* The network addresses of all nodes are within the 192.168.0.* subnet range.
 
* The IP address of the machine running both the NFS exports and the MySQL database is 192.168.0.105.
 
* The IP address of the machine running both the NFS exports and the MySQL database is 192.168.0.105.
Line 130: Line 196:
 
* The Linux user running Kodi is 'kodi' on all nodes.
 
* The Linux user running Kodi is 'kodi' on all nodes.
  
For additional info, refer to the [http://kodi.wiki/index.php?title=HOW-TO:Share_libraries_using_MySQL/Setting_up_MySQL#tab=Arch_Linux official Kodi wiki].
+
For additional info, refer to the [https://kodi.wiki/view/MySQL/Setting_up_MySQL#Arch_Linux official Kodi wiki].
  
==== Setup an NFS server ====
+
=== NFS server export example ===
This section provides an example using NFS exports, but as mentioned above, any protocol that Kodi can read is acceptable.
+
 
 +
This section provides an example using exports, see [[NFS]] for install and usage.
  
{{Warning|Kodi is using {{Pkg|libnfs}} to access NFS shares which only supports NFSv3 (see [https://github.com/sahlberg/libnfs/issues/37 #37] and [https://github.com/sahlberg/libnfs/issues/156 #156]). Therefore do not setup a NFSv4-only server or Kodi will only be able to list the shares but cannot access them.}}
 
 
{{Note|Users only need one box on the LAN to serve the content, therefore, do not repeat this for each node.  The following example assumes the user is running Arch Linux, but any NFS server will work, be it Linux or BSD, etc.}}
 
{{Note|Users only need one box on the LAN to serve the content, therefore, do not repeat this for each node.  The following example assumes the user is running Arch Linux, but any NFS server will work, be it Linux or BSD, etc.}}
  
The NFS server is provided by {{Pkg|nfs-utils}} and this only needs to be installed on the box serving up the content.
+
Create an empty directory in NFS root for each media directory to be shared. E.g.:
  
Setup the shares:
+
  # mkdir -p /srv/nfs/{shows,movies,music}
  # mkdir -p /srv/nfs/{tv-shows,movies,music}
 
# mount --bind /mnt/tv-shows /srv/nfs/tv-shows
 
# mount --bind /mnt/movies /srv/nfs/movies
 
# mount --bind /mnt/music /srv/nfs/music
 
  
Add the corresponding entries for these bind mounts to {{ic|/etc/fstab}}:
+
[[NFS#Server|Bind mount]] the media directories to the empty directories in {{ic|/srv/nfs/}}.
/mnt/tv-shows /srv/nfs/tv-shows none bind 0 0
 
/mnt/movies  /srv/nfs/movies  none bind 0 0
 
/mnt/music    /srv/nfs/music    none bind 0 0
 
  
Share the content in {{ic|/etc/exports}}:
+
Setup [[NFS#Server|exports]]:
  
/srv/nfs          192.168.0.0/24(ro,fsid=0,no_subtree_check)
+
{{hc|/etc/exports.d/kodi.exports|2=
/srv/nfs/tv-shows 192.168.0.0/24(ro,no_subtree_check,insecure)
+
/srv/nfs          192.168.0.0/24(ro,fsid=0,no_subtree_check)
/srv/nfs/movies  192.168.0.0/24(ro,no_subtree_check,insecure)
+
/srv/nfs/shows   192.168.0.0/24(ro,no_subtree_check,insecure)
/srv/nfs/music    192.168.0.0/24(ro,no_subtree_check,insecure)
+
/srv/nfs/movies  192.168.0.0/24(ro,no_subtree_check,insecure)
 
+
/srv/nfs/music    192.168.0.0/24(ro,no_subtree_check,insecure)
{{Tip|This example sets-up read-only exports.  See {{man|5|exports}} for additional options and configurations.}}
+
}}
  
Whenever changes are made to {{ic|/etc/exports}}, always refresh the exports:
+
=== Install and setup the MySQL server ===
# exportfs -rav
 
  
[[Start]] {{ic|rpcbind.service}} and {{ic|nfs-server.service}} and [[enable]] them to start automatically.
+
See [[MariaDB]] for installation and configuration instructions.
  
Optionally check with:
+
To create a database for Kodi, use the following commands:
# showmount -e localhost
 
Export list for localhost:
 
/srv/nfs/tv-shows 192.168.0.0/24
 
/srv/nfs/movies 192.168.0.0/24
 
/srv/nfs/music 192.168.0.0/24
 
 
 
{{Note|If the box is using a firewall, ensure that it is not blocking connections.  This is beyond the scope of this article.}}
 
 
 
==== Install and setup the MySQL server ====
 
The box running the library needs to be available 24/7 and is commonly the same box that holds the media.
 
{{Note|The following example assumes the user is running Arch Linux, but any MySQL server will work, be it Linux or BSD, etc.}}
 
 
 
The MySQL server is provided by {{Pkg|mariadb}} and this only needs to be installed on one box that all nodes can access.
 
 
 
[[Start]] {{ic|mysqld.service}} and [[enable]] it to run at boot time.
 
 
 
First time setup:
 
# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
 
# mysql_secure_installation
 
    <<follow the in-script prompts and answer "Y" to all the questions>>
 
  
 
  $ mysql -u root -p
 
  $ mysql -u root -p
Line 194: Line 232:
 
  MariaDB [(none)]> \q
 
  MariaDB [(none)]> \q
  
One can optionally disable binary logging if the mysql server is only used for kodi by editing {{ic|/etc/mysql/my.cnf}} and commenting the following line:
+
=== Setup Kodi to use the MySQL library and the NFS exports ===
#log-bin=mysql-bin
 
  
No other setup to the MySQL server should be needed.
+
Since this example makes use of NFS shares, an optional dependency of Kodi is now required to access them.  Ensure that each of the Kodi nodes has {{Pkg|libnfs}} installed.
{{Note|If the box is using a firewall, ensure that it is not blocking connections.  This is beyond the scope of this article.}}
 
  
==== Setup Kodi to use the MySQL library and the NFS exports ====
+
==== Setup Kodi to use the common MySQL database ====
Since this example makes use of NFS shares, an optional dependency of Kodi is now required to access them.  Ensure that each of the Kodi nodes has {{Pkg|libnfs}} installed.
 
  
===== Setup Kodi to use the common MySQL database =====
 
 
To tell Kodi to use the common database, insure that Kodi is not running, then create the following file:
 
To tell Kodi to use the common database, insure that Kodi is not running, then create the following file:
 +
 
{{hc|~/.kodi/userdata/advancedsettings.xml|
 
{{hc|~/.kodi/userdata/advancedsettings.xml|
 
<advancedsettings>
 
<advancedsettings>
Line 232: Line 267:
 
{{Tip|If using {{AUR|kodi-standalone-service}}, the default for the profile is {{ic|/var/lib/kodi/.kodi}} and be sure to chown the newly created file to the kodi user and group, i.e. {{ic|chown -R kodi:kodi /var/lib/kodi}}}}
 
{{Tip|If using {{AUR|kodi-standalone-service}}, the default for the profile is {{ic|/var/lib/kodi/.kodi}} and be sure to chown the newly created file to the kodi user and group, i.e. {{ic|chown -R kodi:kodi /var/lib/kodi}}}}
  
===== Setup network shares =====
+
==== Setup network shares ====
Load Kodi and define the network shares that correspond to the exports by browsing to the following within the interface:
+
 
Video>Files>Add Videos>Browse>Network Filesystem(NFS)
+
Load Kodi and define the network shares that correspond to the exports by browsing to the following within the interface ''Video > Files > Add Videos > Browse > Network Filesystem(NFS)''.
  
 
After a few seconds, the IP address corresponding to the NFS server should appear.
 
After a few seconds, the IP address corresponding to the NFS server should appear.
  
Select {{ic|/srv/nfs/tv-shows}} from the list of share and then "OK" from the menu on the right.  Assign this share the category of "TV Shows" to setup the appropriate scraper and to populate the MySQL database with the correct metadata.
+
Select {{ic|/srv/nfs/shows}} from the list of share and then ''OK'' from the menu on the right.  Assign this share the category of ''TV Shows'' to setup the appropriate scraper and to populate the MySQL database with the correct metadata.
  
 
Repeat this browsing process for the "movies" and "music" and then exit Kodi once properly configured.  At this point, the MySQL tables should have been created.
 
Repeat this browsing process for the "movies" and "music" and then exit Kodi once properly configured.  At this point, the MySQL tables should have been created.
  
{{Note|Even if Kodi is running on the same box that is also running the NFS exports and MySQL server, one '''must''' setup the media using the nfs shares only!}}
+
{{Note|Even if Kodi is running on the same box that is also running the NFS exports and MySQL server, one '''must''' setup the media using the nfs shares only.}}
  
==== Cloning the configuration to other nodes on the network ====
+
=== Cloning the configuration to other nodes on the network ===
To set up another Kodi node on the network to use this library, simply copy {{ic|~/.kodi/userdata/advancedsettings.xml}} to that box and restart Kodi.
 
  
{{Note|There is NO need to copy any other files or to do any other setup steps on the new kodi node. The nfs exports, the metadata for the programming, any stop/start times, view status, etc. are all stored in the MySQL tables.}}
+
To set up another Kodi node on the network to use this library, simply copy {{ic|~/.kodi/userdata/advancedsettings.xml}} to that box and restart Kodi.  There is NO need to copy any other files or to do any other setup steps on the new kodi node. The nfs exports, the metadata for the programming, any stop/start times, view status, etc. are all stored in the MySQL tables.
  
=== Using a remote control ===
+
{{Note|One can optionally define other media sources that are not managed by kodi database, but they will be specific to that particular node.}}
As Kodi is geared toward being a remote-controlled media center via an official app, physical remote control, or USB/bluetooth keyboard/mouse.
 
  
==== Using the Android or iOS app ====
+
== Tips and Tricks ==
Both Android and iOS users can use the official app (currently free of charge) to control kodi once it is correctly setup to do so.  Steps to configure both Kodi and the app are detailed on the [http://kodi.wiki/view/Official_Kodi_Remote Official Kodi Remote] page.
 
  
==== Using a physical remote control ====
+
=== Keep a log of what is watched ===
Any PC with a supported IR receiver/remote, can use remote using [[LIRC]] or using the native kernel supported modules.  Configuring specific remotes with lirc is covered on the [[LIRC]] article.
 
  
To work properly with Kodi, a file will be required that maps the lirc events to Kodi keypresses.  Create an [[Wikipedia:XML|XML]] file at {{ic|~/.kodi/userdata/Lircmap.xml}} (note the capital 'L').  
+
Keep track of every video watched on kodi with {{AUR|kodi-logger}}.
  
{{Note|Users running Kodi started with {{AUR|kodi-standalone-service}} will find the kodi home (~) under {{ic|/var/lib/kodi}} and should substitute this in for the shortcut above.  Also make sure that if creating this file as the root user, it gets proper ownership as kodi:kodi when finished.}}
+
=== CLI tool for kodi ===
Lircmap.xml format is as follows:
 
 
 
{{bc|1=<lircmap>
 
  <remote device="devicename">
 
      <XBMC_button>LIRC_button</XBMC_button>
 
      ...
 
  </remote>
 
</lircmap>}}
 
 
 
* '''Device Name''' is whatever LIRC calls the remote. This is set using the '''Name''' directive in lircd.conf and can be viewed by running {{ic|$ irw}} and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
 
 
 
* '''XBMC_button''' is the name of the button as defined in [http://kodi.wiki/index.php?title=Keymap.xml keymap.xml].
 
 
 
* '''LIRC_button''' is the name as defined in {{ic|lircd.conf}}. If lircd.conf was autogenerated using {{ic|# irrecord}}, these are the names selected for the buttons. Refer back to [[LIRC]] for more information.
 
 
 
* A very thorough [http://kodi.wiki/index.php?title=Lircmap.xml Lircmap.xml page] hosted on the [http://kodi.wiki/index.php?title=Main_Page Kodi Wiki] should be consulted for more help and information on this subject as this is out of scope of this article.
 
 
 
=== HDMI-CEC with Pulse Eight USB-CEC ===
 
 
 
An elegant way of getting remote functions in Kodi is using [[wikipedia:Consumer_Electronics_Control#CEC|CEC]], a protocol that is part of the HDMI specification. Most modern TVs support CEC, although some manufacturers advertise the feature under other names. Apart from a CEC-enabled TV some hardware that takes the CEC signals coming from the TV and present them in a way that Kodi can understand is also needed. One such device is the [http://www.pulse-eight.com/store/products/104-usb-hdmi-cec-adapter.aspx USB-CEC adapter] from Pulse Eight. Hooking up the USB-CEC is pretty simple, but in order for it to work in Arch we have to do a few things.
 
 
 
Install {{ic|libcec}}.
 
 
 
When connected, the USB-CEC's {{ic|/dev}} entry (usually {{ic|/dev/ttyACM*}}) will default to being owned by the {{ic|uucp}} group, so in order to use the device the user running Kodi needs to belong to that group. The user also needs to belong to the {{ic|lock}} group, otherwise Kodi will be unable to connect to the device. To add a user to both groups, run
 
 
 
# usermod -aG uucp,lock [username]
 
 
 
If more than one user uses Kodi, repeat the command for all those users. If, for example, one is using {{ic|kodi-standalone}}, the relevant command is
 
 
 
# usermod -aG uucp,lock kodi
 
  
Remember that modifying the groups of any logged in users means those users need to log out and login again in order for the changes to take effect.
+
A powerful CLI tool for use with kodi is {{AUR|texturecache}}.  Users can accomplish many tasks from library management to querying what is currently playing.
  
{{Note|Trying to use the USB-CEC without belonging to above groups may lead to problems, including Kodi crashes, so make sure the correct user belongs to both groups.}}
+
=== Hardware video acceleration ===
  
==Tips and Tricks ==
 
=== Keep a log of what is watched ===
 
Keep track of every video watched on kodi with {{AUR|kodi-logger}}.
 
 
=== CLI tool for kodi ===
 
A powerful CLI tool for use with kodi is {{AUR|texturecache}}.  Users can accomplish many task from library management to querying what is currently playing.
 
 
=== Enable Hardware video acceleration ===
 
 
Enable and configure [[Hardware video acceleration]] to speed up playback performance.
 
Enable and configure [[Hardware video acceleration]] to speed up playback performance.
  
Line 310: Line 303:
 
=== Adjusting CD/DVD drive speed ===
 
=== Adjusting CD/DVD drive speed ===
  
The {{ic|eject}} program from the {{ic|util-linux}} package does a nice job for this, but its setting is cleared as soon as the media is changed.
+
The ''eject'' program from the {{Pkg|util-linux}} package does a nice job for this, but its setting is cleared as soon as the media is changed.
  
 
This udev-rule reduces the speed permanently:
 
This udev-rule reduces the speed permanently:
Line 321: Line 314:
  
 
After creating the file, reload the udev rules with
 
After creating the file, reload the udev rules with
 +
 
  # udevadm control --reload
 
  # udevadm control --reload
  
Line 326: Line 320:
  
 
Kodi has a webservice that allows interaction through a web-interface. By default, it uses port {{ic|8080}} as {{ic|80}} requires root privileges. Use the following to permit it to use low port numbers:
 
Kodi has a webservice that allows interaction through a web-interface. By default, it uses port {{ic|8080}} as {{ic|80}} requires root privileges. Use the following to permit it to use low port numbers:
  # setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin
 
  
[[Restart]] {{ic|kodi.service}} and set port {{ic|80}} in the configuration menu (''Services->Webserver->Port'').
+
# setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin
 +
 
 +
Restart Kodi and set port {{ic|80}} in the configuration menu (''Services > Webserver > Port'').
  
 
=== Using ALSA ===
 
=== Using ALSA ===
  
If [[PulseAudio]] does not work properly, try using ALSA directly by starting Kodi with the {{ic|1=AE_SINK=ALSA}} environment variable.  The Kodi wiki for NUC devices provides [http://kodi.wiki/view/HOW-TO:Install_Kodi_on_an_Intel_NUC#disable_PulseAudio instructions]
+
If [[PulseAudio]] does not work properly, try using [[ALSA]] directly by starting Kodi with the {{ic|1=AE_SINK=ALSA}} [[environment variable]].  The Kodi wiki for NUC devices provides [https://kodi.wiki/view/HOW-TO:Install_Kodi_on_an_Intel_NUC#disable_PulseAudio instructions]
 +
 
 +
If using {{ic|kodi-standalone}}, change the {{ic|APP}} variable in {{ic|/usr/bin/kodi-standalone}} to
  
=== Raspberry Pi (all generations) ===
+
APP="${bindir}/pasuspender -- env AE_SINK=ALSA ${bindir}/${bin_name} --standalone $@"
  
Kodi runs smoothly on the Raspberry Pi (RPi), RPi2, and RPi3. Some helpful tips to consider:
+
=== Audio Passthrough ===
* [[Install]] either the ''kodi-rbp'' (stable) or ''kodi-rbp-git'' (dev) package instead of ''kodi'' from the [http://archlinuxarm.org/packages Arch Linux ARM repository].
 
* This package ships with a systemd service to run in standalone mode.
 
* The memory reserved for GPU is 64 MB by default. This is insufficient for GPU accelerated HD video playback. Users can increase this value via a simple edit to the {{ic|gpu_mem}} tag in {{ic|/boot/config.txt}}.  A value of at least 128 MB is recommended for RPi version 1 while a value of 256 is recommended for RPi2 and 3.
 
  
=== TV is not detected unless powered on first ===
+
To allow the receiver to decode the audio by enabling passthrough. This is useful for files encoded in TrueHD or Atmos. If using PulseAudio, follow the instructions at https://kodi.wiki/view/PulseAudio to first enable passthrough in PulseAudio. Then the passthrough options will appear in Kodi. If using ALSA, the passthrough options will appear in Kodi without modifications.
Some TVs (LG brand for example) only report their capabilities via EDID through HDMI when powered on '''before''' the RPi. The effects of this can manifest in one of two ways:
 
# Despite being connected, the TV will be unable to detect a signal from the HDMI source until the RPi is rebooted.
 
# The signal will be detected but incorrectly by the RPi to the point of the GUI looking distorted when compared to having the TV on first, then rebooting the RPi.
 
  
Both conditions are easily fixed. See: [http://kodi.wiki/view/Raspberry_Pi_FAQ#TV_is_not_detected_unless_powered_on_first Raspberry_Pi_FAQ#TV_is_not_detected_unless_powered_on_first].
+
{{Warning|PulseAudio requires the output in Kodi to be set to 2 channel. Audio encoded in formats not passed through will only be sent as stereo audio. Use ALSA to support passthrough and passing decoded surround audio signals}}
 +
 
 +
{{Note|PulseAudio does not support TrueHD, DTS-MA, or Atmos passthrough. Use ALSA to pass these to through the receiver.}}
 +
 
 +
==== Fix for delayed startup on wifi ====
 +
 
 +
If running with WiFi only (wired network unplugged) while [[#Sharing media and a centralized database across multiple nodes]], kodi will likely start before the wireless network is up, which will result in failure to connect to the shares and to the mysql server.  Assuming the network is managed by the default [[systemd-networkd]], this can be fixed by using two [[Systemd#Drop-in files]], one for {{ic|kodi.service}} and another for {{ic|systemd-networkd-wait-online.service}}:
 +
 
 +
# systemctl edit systemd-networkd-wait-online.service
 +
[Service]
 +
ExecStart=
 +
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --ignore eth0
 +
 
 +
# systemctl edit kodi
 +
[Unit]
 +
After=remote-fs.target network-online.target
 +
Wants=network-online.target
 +
 
 +
=== Run kodi in a window manager ===
  
==== Run kodi in a window manager ====
 
 
Users running kodi in a [[Window manager]] may see a black screen at exit.  To fix this, try switching to another tty.  A possible solution is to run kodi with this script (running as the root user):
 
Users running kodi in a [[Window manager]] may see a black screen at exit.  To fix this, try switching to another tty.  A possible solution is to run kodi with this script (running as the root user):
 +
 
{{hc|kodi.sh|
 
{{hc|kodi.sh|
 
#!/bin/bash
 
#!/bin/bash
Line 357: Line 366:
 
sudo chvt 1
 
sudo chvt 1
 
}}
 
}}
 +
 
To make sure that [[sudo]] does not ask for password for {{ic|chvt}} add this line to {{ic|sudoers}} file:
 
To make sure that [[sudo]] does not ask for password for {{ic|chvt}} add this line to {{ic|sudoers}} file:
 +
 
{{hc|/etc/sudoers|
 
{{hc|/etc/sudoers|
 
''UserNameHere'' ALL&#61;NOPASSWD: /usr/bin/chvt
 
''UserNameHere'' ALL&#61;NOPASSWD: /usr/bin/chvt
 
}}
 
}}
  
==== USB DAC not working ====
+
=== USB DAC not working ===
 +
 
 
Users of USB DAC/sound cards may experience distorted sound/clicks/pops or no sound at all when selecting it from Audio settings.  A possible fix:  
 
Users of USB DAC/sound cards may experience distorted sound/clicks/pops or no sound at all when selecting it from Audio settings.  A possible fix:  
  
Line 375: Line 387:
 
== Troubleshooting ==
 
== Troubleshooting ==
  
===Accessing kodi logs ===
+
=== Accessing Kodi logs ===
In case of an error the first point to start investigation can be {{ic|~/.kodi/temp/kodi.log}}.  
+
 
 +
In case of an error the first point to start investigation can be {{ic|~/.kodi/temp/kodi.log}}.
  
 
=== Fullscreen mode stretches Kodi across multiple displays ===
 
=== Fullscreen mode stretches Kodi across multiple displays ===
  
For a multi-monitor setup, Kodi may default to stretching across all screens.  One can restrict the fullscreen mode to one display by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example, having Kodi show up on display 0, add the following line to the Kodi user's {{ic|~/.bashrc}} configuration:
+
For a multi-monitor setup, Kodi may default to stretching across all screens.  One can restrict the fullscreen mode to one display by setting the [[environment variable]] {{ic|SDL_VIDEO_FULLSCREEN_HEAD}} to the number of the desired target display. For example, having Kodi show up on display 0, add the following line to the Kodi user's {{ic|~/.bashrc}} configuration:
  
 
  SDL_VIDEO_FULLSCREEN_HEAD=0
 
  SDL_VIDEO_FULLSCREEN_HEAD=0
Line 387: Line 400:
  
 
=== Video tearing on Intel HD Graphics ===
 
=== Video tearing on Intel HD Graphics ===
Users observing tearing when watching a movie try this:
+
 
https://bbs.archlinux.org/viewtopic.php?id=176651
+
Users observing tearing when watching a movie try this: https://bbs.archlinux.org/viewtopic.php?id=176651
  
 
Try a different X11 compositor like {{Pkg|compton}} as an alternative with [[Xfce]] which reduces video tearing. There is no essential need to install the intel driver. A tutorial how to configure compton with Xfce can be found [http://duncanlock.net/blog/2013/06/07/how-to-switch-to-compton-for-beautiful-tear-free-compositing-in-xfce/ here].
 
Try a different X11 compositor like {{Pkg|compton}} as an alternative with [[Xfce]] which reduces video tearing. There is no essential need to install the intel driver. A tutorial how to configure compton with Xfce can be found [http://duncanlock.net/blog/2013/06/07/how-to-switch-to-compton-for-beautiful-tear-free-compositing-in-xfce/ here].
Line 398: Line 411:
 
=== H.264 playback is using only a single core ===
 
=== H.264 playback is using only a single core ===
  
{{Tip|By default, press {{ic|O}} during playback to show codec information and CPU usage. More information about this overlay can be found [http://kodi.wiki/view/Codecinfo here].}}
+
{{Tip|By default, press {{ic|O}} during playback to show codec information and CPU usage. More information about this overlay can be found at https://kodi.wiki/view/Codecinfo.}}
  
If your setup does not or cannot make use of hardware acceleration, disable it and explicitly set video decoding to software.
+
If the hardware does not or cannot make use of acceleration, disable it and explicitly set video decoding to software.
This is because [http://forum.kodi.tv/showthread.php?tid=170084&pid=1789661#pid1789661 H.264 decoding is only multithreaded when video decoding is set to software].
+
This is because [https://forum.kodi.tv/showthread.php?tid=170084&pid=1789661#pid1789661 H.264 decoding is only multithreaded when video decoding is set to software].
To achieve this, go to {{ic|System Settings}} and then to {{ic|Video}}. Set the {{ic|settings level}} to {{ic|Advanced}} or {{ic|Expert}} and go to {{ic|Acceleration}}.
+
 
There, set {{ic|Decoding method}} to {{ic|software}}.
+
To achieve this, go to ''System Settings > Video''. Set the {{ic|settings level}} to {{ic|Advanced}} or {{ic|Expert}}. Then go to ''Acceleration'' and set {{ic|Decoding method}} to {{ic|software}}.
  
 
=== Kodi hangs on exit, fully occupying one CPU core, UI unresponsive ===
 
=== Kodi hangs on exit, fully occupying one CPU core, UI unresponsive ===
Line 409: Line 422:
 
This problem can arise with third-party plugins installed, there is some issue with their termination[https://www.linuxquestions.org/questions/linux-software-2/kodi-freezes-on-exit-kodi-bin-won't-die-4175588180/],[https://www.reddit.com/r/archlinux/comments/5029oo/kodi_freezes_on_exit_kodibin_wont_die/].
 
This problem can arise with third-party plugins installed, there is some issue with their termination[https://www.linuxquestions.org/questions/linux-software-2/kodi-freezes-on-exit-kodi-bin-won't-die-4175588180/],[https://www.reddit.com/r/archlinux/comments/5029oo/kodi_freezes_on_exit_kodibin_wont_die/].
  
Workaround: find proper UI description file (''DialogButtonMenu.xml'') and tweak exit button type from internal Kodi's ''Quit()'' function call to sending signal from outside system to Kodi. Here is one-liner that makes modifications to any skin from your default Kodi package:
+
Workaround: find proper UI description file ({{ic|DialogButtonMenu.xml}}) and tweak exit button type from internal Kodi's {{ic|Quit()}} function call to sending signal from outside system to Kodi. Here is one-liner that makes modifications to any skin from the default Kodi package:
  find /usr/share/kodi/addons/skin.* -name DialogButtonMenu.xml | xargs sudo sed -i "s%<onclick>Quit()</onclick>%<onclick>System.Exec ("killall --signal SIGHUP kodi.bin")</onclick>%"
+
 
 +
  # find /usr/share/kodi/addons/skin.* -name DialogButtonMenu.xml -exec sed -i 's%<onclick>Quit()</onclick>%<onclick>System.Exec ("killall --signal SIGHUP kodi.bin")</onclick>%' {} \;
  
 
== See also ==
 
== See also ==
  
* [http://kodi.wiki/index.php?title=Main_Page Kodi Wiki] - Excellent resource with much information about Arch Linux specifically
+
* [https://kodi.wiki/view/Main_Page Kodi Wiki] - Excellent resource with much information about Arch Linux specifically
* http://superrepo.org/ - xbmc Plug-in library
+
* [[Wikipedia:Kodi (software)]]
 +
* http://superrepo.org/{{Dead link|2018|06|13}} - xbmc Plug-in library
 
* http://www.hdpfans.com/thread-329076-1-1.html - Kodi/xbmc Chinese plug-in library installation method
 
* http://www.hdpfans.com/thread-329076-1-1.html - Kodi/xbmc Chinese plug-in library installation method
* https://github.com/taxigps/xbmc-addons-chinese - xbmc-addons-chinese
+
* https://github.com/taxigps/xbmc-addons-chinese - xbmc-addons-chinese: Addon scripts, plugins, and skins for XBMC Media Center. Special for chinese laguage.
{{Note|xbmc-addons-chinese:Addon scripts, plugins, and skins for XBMC Media Center. Special for chinese laguage.}}
 

Latest revision as of 13:25, 20 October 2018

Kodi (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls. These can all be played directly from a CD/DVD, or from the hard-drive. Kodi can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. It can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the Kodi wiki.

Installation

The official stable release can be installed via the kodi package. Alternatively, recent alpha, beta, or RC builds are available from kodi-pre-releaseAUR. Be sure to review/install optional dependencies listed by pacman to enable additional functionality.

All of the official addons in the kodi-addons group are disabled by default and need to be enabled in Kodi's addon menu after installation.

Running

The kodi package supplies two binaries for two different use cases:

  1. /usr/bin/kodi is meant to be run by any user on an on-demand basis. Use it like any other program on the system.
  2. /usr/bin/kodi-standalone is meant to be run as the only graphical application, for example on a HTPC. See #Running standalone for more information.

Running standalone

Using standalone mode is advantageous for several reasons:

  1. The default kodi user is unprivileged and cannot access a shell.
  2. When paired with a systemd unit (or equivalent, see below), this setup makes the box on which kodi is running more like an appliance.
Warning: Select only one of the methods listed below.

kodi-standalone service

The kodi-standalone-serviceAUR package provides kodi.service and automatically creates the unprivileged user to run Kodi in standalone mode. Although the correct driver is an assumed dependency, no extra Xorg packages are needed.

Start kodi.service and enable it to run at boot time.

Note:
  • If kodi.service fails to start, see Xorg#Rootless Xorg.
  • The home directory for the created kodi user is /var/lib/kodi/.

Xsession with LightDM

Note:
  • This assumes that a kodi user named kodi is on the system and that the following file is present as described.
  • lightdm does not pull in an X server as a required dependency, it is optional. The X server listed as an optional dependency (xorg-server-xephyr) does not work when run as root by lightdm.service (FS#52067, LightDM Bug 852577). Install xorg-server.

To use LightDM with automatic login, see LightDM#Enabling autologin and LightDM#Enabling interactive passwordless login. Kodi includes kodi.desktop as xsession.

/etc/lightdm/lightdm.conf
[Seat:seat0]
pam-service=lightdm-autologin
autologin-user=kodi
autologin-user-timeout=0
user-session=kodi

Socket activation

Socket activation can be used to start Kodi when the user starts a remote control app or on a connection to Kodi's html control port. Start listening by starting kodi@user.socket (replace user with the user running Kodi to be started as).

There are no packaged kodi@.socket and kodi@.socket files, one must create them manually. Depending on the setup, one can optionally change the port in kodi@.socket.

/etc/systemd/system/kodi@.service
# This fails if the user does not have an X session.
[Unit]
Description=Launch Kodi on main display
Conflicts=kodi.socket

[Service]
Type=simple
Environment=DISPLAY=:0.0
Nice=-1
ExecStart=/usr/bin/su %i /usr/bin/kodi
ExecStopPost=/usr/bin/systemctl --no-block start kodi@%i.socket

[Install]
WantedBy=multi-user.target
/etc/systemd/system/kodi@.socket
[Unit]
Conflicts=kodi@%i.service

[Socket]
# listen for WOL packets
#ListenDatagram=9

# change this to Kodi's http control port
ListenStream=8082

[Install]
WantedBy=sockets.target

Start from remote control with LIRC / irexec

Kodi can be configured to start via a key press. Users will need kodi-standalone-serviceAUR and lirc. This can be useful on setups running 24/7 and having kodi up on demand.

See the corresponding LIRC article and create a functional setup with a remote. Also, the package kodi-standalone-serviceAUR has to be installed.

Generate the file /var/lib/kodi/.lircrc with the following content:

/var/lib/kodi/.lircrc
begin
prog = irexec
remote = devinput
button = KEY_MEDIA
config = pgrep kodi-standalone || /usr/bin/kodi-standalone -l /run/lirc/lircd
repeat = 0
end

Adopt button to whatever button on the remote is to start Kodi. One can use irw (see LIRC#Usage) to find out the correct values for remote and button.

Create a drop-in for kodi.service:

/etc/systemd/system/kodi.service.d/lirc.conf
[Service]
ExecStart =
ExecStart = /usr/bin/irexec

Start kodi.service and enable it to run at boot time.

Using a remote control

As Kodi is geared toward being a remote-controlled media center via an official app, physical remote control, or USB/bluetooth keyboard/mouse.

Using the Android or iOS app

Both Android and iOS users can use the official app (currently free of charge) to control kodi once it is correctly setup to do so. Steps to configure both Kodi and the app are detailed on the Official Kodi Remote page.

Using a physical remote control

Any PC with a supported IR receiver/remote, can use LIRC or even kernel supported modules to drive it. Configuring specific remotes with lirc is covered on the LIRC article.

To work properly with Kodi, a file that maps the lirc events to Kodi keypresses is needed. Create an XML file at ~/.kodi/userdata/Lircmap.xml (note the capital 'L').

Note: Users running Kodi started with kodi-standalone-serviceAUR will find the kodi user's home (~) under /var/lib/kodi/ and should substitute this in for the shortcut above. Also make sure that if creating this file as the root user, it gets proper ownership as kodi:kodi when finished.

Lircmap.xml format is as follows:

<lircmap>
  <remote device="devicename">
      <XBMC_button>LIRC_button</XBMC_button>
      ...
  </remote>
</lircmap>
  • Device Name is whatever LIRC calls the remote. This is set using the Name directive in lircd.conf and can be viewed by running irw and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
  • XBMC_button is the name of the button as defined in keymap.xml.
  • LIRC_button is the name as defined in lircd.conf. If lircd.conf was autogenerated using irrecord, these are the names selected for the buttons. Refer back to LIRC for more information.
  • A very thorough LIRC page hosted on the Kodi Wiki should be consulted for more help and information on this subject as this is out of scope of this article.

HDMI-CEC

With a supported USB-CEC adapter, Kodi can be used to automatically turn on and off the TV and other home theater equipment. Volume control from Kodi can be sent to a supported amplifier, one can manage DVD or Blu-Ray players from inside Kodi, and redirect the active source on the TV to whichever equipment needs it, all from one remote control. For more information see the official Kodi wiki page on CEC and libCEC FAQ.

Install libcec.

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Add reference for the need to add users to these groups. (Discuss in Talk:Kodi#)

When connected, the USB-CEC's /dev entry (usually /dev/ttyACM*) will default to being owned by the uucp group, so in order to use the device the user running Kodi needs to belong to that group. The user also needs to belong to the lock group, otherwise Kodi will be unable to connect to the device. See Users and groups#Group management for instructions on how to add users to groups.

Note: Trying to use the USB-CEC without belonging to above groups may lead to problems, including Kodi crashes, so make sure the correct user belongs to both groups.

Sharing media and a centralized database across multiple nodes

If multiple PCs on the same network are running Kodi, they can be configured to share a single media library (video and music). The advantage of this is media and key metadata are stored in one place, and are shared/updated by all nodes on the network. For example, users of this setup can:

  • Stop watching a movie or show in one room then finish watching it in another room automatically.
  • Share watched and unwatched status for media on all nodes.
  • Simplify the setup with only a single library to maintain.

As well, the media itself can be located in one space thus allowing a lighter footprint of client systems (ie no need for large HDD space).

Several things are needed for this to work:

  • Network exposed media (via protocols that Kodi can read, e.g. NFS or Samba).
  • A MySQL server.
Warning: When sharing a database, ALL clients need to be on the same major version of Kodi due to versioned requirements of the database schema. Refer to this table for a list of database versions.
Note: The following guide is only an example of one configuration and is not meant to be limiting but illustrative. Key steps are shown but a detailed discussion is not offered.

These assumptions are used for the guide, substitute as needed:

  • The media is located under following mount points: /mnt/shows /mnt/movies /mnt/music.
  • The network addresses of all nodes are within the 192.168.0.* subnet range.
  • The IP address of the machine running both the NFS exports and the MySQL database is 192.168.0.105.
  • Each Kodi box is referred to as a node.
  • The Linux user running Kodi is 'kodi' on all nodes.

For additional info, refer to the official Kodi wiki.

NFS server export example

This section provides an example using exports, see NFS for install and usage.

Note: Users only need one box on the LAN to serve the content, therefore, do not repeat this for each node. The following example assumes the user is running Arch Linux, but any NFS server will work, be it Linux or BSD, etc.

Create an empty directory in NFS root for each media directory to be shared. E.g.:

# mkdir -p /srv/nfs/{shows,movies,music}

Bind mount the media directories to the empty directories in /srv/nfs/.

Setup exports:

/etc/exports.d/kodi.exports
/srv/nfs          192.168.0.0/24(ro,fsid=0,no_subtree_check)
/srv/nfs/shows    192.168.0.0/24(ro,no_subtree_check,insecure)
/srv/nfs/movies   192.168.0.0/24(ro,no_subtree_check,insecure)
/srv/nfs/music    192.168.0.0/24(ro,no_subtree_check,insecure)

Install and setup the MySQL server

See MariaDB for installation and configuration instructions.

To create a database for Kodi, use the following commands:

$ mysql -u root -p
   <<enter the mysqld root password assigned in the first step>>
MariaDB [(none)]> CREATE USER 'kodi' IDENTIFIED BY 'kodi';
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> \q

Setup Kodi to use the MySQL library and the NFS exports

Since this example makes use of NFS shares, an optional dependency of Kodi is now required to access them. Ensure that each of the Kodi nodes has libnfs installed.

Setup Kodi to use the common MySQL database

To tell Kodi to use the common database, insure that Kodi is not running, then create the following file:

~/.kodi/userdata/advancedsettings.xml
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.0.105</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase>

  <musicdatabase>
    <type>mysql</type>
    <host>192.168.0.105</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>

  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>
Tip: If using kodi-standalone-serviceAUR, the default for the profile is /var/lib/kodi/.kodi and be sure to chown the newly created file to the kodi user and group, i.e. chown -R kodi:kodi /var/lib/kodi

Setup network shares

Load Kodi and define the network shares that correspond to the exports by browsing to the following within the interface Video > Files > Add Videos > Browse > Network Filesystem(NFS).

After a few seconds, the IP address corresponding to the NFS server should appear.

Select /srv/nfs/shows from the list of share and then OK from the menu on the right. Assign this share the category of TV Shows to setup the appropriate scraper and to populate the MySQL database with the correct metadata.

Repeat this browsing process for the "movies" and "music" and then exit Kodi once properly configured. At this point, the MySQL tables should have been created.

Note: Even if Kodi is running on the same box that is also running the NFS exports and MySQL server, one must setup the media using the nfs shares only.

Cloning the configuration to other nodes on the network

To set up another Kodi node on the network to use this library, simply copy ~/.kodi/userdata/advancedsettings.xml to that box and restart Kodi. There is NO need to copy any other files or to do any other setup steps on the new kodi node. The nfs exports, the metadata for the programming, any stop/start times, view status, etc. are all stored in the MySQL tables.

Note: One can optionally define other media sources that are not managed by kodi database, but they will be specific to that particular node.

Tips and Tricks

Keep a log of what is watched

Keep track of every video watched on kodi with kodi-loggerAUR.

CLI tool for kodi

A powerful CLI tool for use with kodi is texturecacheAUR. Users can accomplish many tasks from library management to querying what is currently playing.

Hardware video acceleration

Enable and configure Hardware video acceleration to speed up playback performance.

Restart Kodi and enable the hardware backend(s) in Playback under Settings.

Adjusting CD/DVD drive speed

The eject program from the util-linux package does a nice job for this, but its setting is cleared as soon as the media is changed.

This udev-rule reduces the speed permanently:

/etc/udev/rules.d/dvd-speed.rules
KERNEL=="sr0", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1", RUN+="/usr/bin/eject -x 2 /dev/sr0"

Replace sr0 with the device name of the optical drive. Replace -x 2 with -x 4 if the preference is 4x-speed instead of 2x-speed.

After creating the file, reload the udev rules with

# udevadm control --reload

Use port 80 for webserver

Kodi has a webservice that allows interaction through a web-interface. By default, it uses port 8080 as 80 requires root privileges. Use the following to permit it to use low port numbers:

# setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin

Restart Kodi and set port 80 in the configuration menu (Services > Webserver > Port).

Using ALSA

If PulseAudio does not work properly, try using ALSA directly by starting Kodi with the AE_SINK=ALSA environment variable. The Kodi wiki for NUC devices provides instructions

If using kodi-standalone, change the APP variable in /usr/bin/kodi-standalone to

APP="${bindir}/pasuspender -- env AE_SINK=ALSA ${bindir}/${bin_name} --standalone $@"

Audio Passthrough

To allow the receiver to decode the audio by enabling passthrough. This is useful for files encoded in TrueHD or Atmos. If using PulseAudio, follow the instructions at https://kodi.wiki/view/PulseAudio to first enable passthrough in PulseAudio. Then the passthrough options will appear in Kodi. If using ALSA, the passthrough options will appear in Kodi without modifications.

Warning: PulseAudio requires the output in Kodi to be set to 2 channel. Audio encoded in formats not passed through will only be sent as stereo audio. Use ALSA to support passthrough and passing decoded surround audio signals
Note: PulseAudio does not support TrueHD, DTS-MA, or Atmos passthrough. Use ALSA to pass these to through the receiver.

Fix for delayed startup on wifi

If running with WiFi only (wired network unplugged) while #Sharing media and a centralized database across multiple nodes, kodi will likely start before the wireless network is up, which will result in failure to connect to the shares and to the mysql server. Assuming the network is managed by the default systemd-networkd, this can be fixed by using two Systemd#Drop-in files, one for kodi.service and another for systemd-networkd-wait-online.service:

# systemctl edit systemd-networkd-wait-online.service
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --ignore eth0
# systemctl edit kodi
[Unit]
After=remote-fs.target network-online.target
Wants=network-online.target

Run kodi in a window manager

Users running kodi in a Window manager may see a black screen at exit. To fix this, try switching to another tty. A possible solution is to run kodi with this script (running as the root user):

kodi.sh
#!/bin/bash
kodi-standalone
sudo chvt 2 
sleep 1
sudo chvt 1

To make sure that sudo does not ask for password for chvt add this line to sudoers file:

/etc/sudoers
UserNameHere ALL=NOPASSWD: /usr/bin/chvt

USB DAC not working

Users of USB DAC/sound cards may experience distorted sound/clicks/pops or no sound at all when selecting it from Audio settings. A possible fix:

Open guisettings.xml (it should be under /var/lib/kodi/.kodi/userdata/ if using the supplied kodi.service) and change

<processquality default="true">101</processquality>

to

<processquality default="false">100</processquality>

Troubleshooting

Accessing Kodi logs

In case of an error the first point to start investigation can be ~/.kodi/temp/kodi.log.

Fullscreen mode stretches Kodi across multiple displays

For a multi-monitor setup, Kodi may default to stretching across all screens. One can restrict the fullscreen mode to one display by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example, having Kodi show up on display 0, add the following line to the Kodi user's ~/.bashrc configuration:

SDL_VIDEO_FULLSCREEN_HEAD=0
Note: Mouse cursor will be held inside screen with Kodi.

Video tearing on Intel HD Graphics

Users observing tearing when watching a movie try this: https://bbs.archlinux.org/viewtopic.php?id=176651

Try a different X11 compositor like compton as an alternative with Xfce which reduces video tearing. There is no essential need to install the intel driver. A tutorial how to configure compton with Xfce can be found here.

Soft subtitles not displaying

The ffmpeg package is used to extract the subtitles.

H.264 playback is using only a single core

Tip: By default, press O during playback to show codec information and CPU usage. More information about this overlay can be found at https://kodi.wiki/view/Codecinfo.

If the hardware does not or cannot make use of acceleration, disable it and explicitly set video decoding to software. This is because H.264 decoding is only multithreaded when video decoding is set to software.

To achieve this, go to System Settings > Video. Set the settings level to Advanced or Expert. Then go to Acceleration and set Decoding method to software.

Kodi hangs on exit, fully occupying one CPU core, UI unresponsive

This problem can arise with third-party plugins installed, there is some issue with their termination[1],[2].

Workaround: find proper UI description file (DialogButtonMenu.xml) and tweak exit button type from internal Kodi's Quit() function call to sending signal from outside system to Kodi. Here is one-liner that makes modifications to any skin from the default Kodi package:

# find /usr/share/kodi/addons/skin.* -name DialogButtonMenu.xml -exec sed -i 's%<onclick>Quit()</onclick>%<onclick>System.Exec ("killall --signal SIGHUP kodi.bin")</onclick>%' {} \;

See also