Kodi

From Gentoo Wiki
(Redirected from XBMC)
Jump to: navigation, search

Kodi (formerly XBMC) is an open source home theater application.

Installation

USE flags

USE flags for media-tv/kodi A free and open source media-player and entertainment hub

airplay enable AirPlay support
bluray Enable playback of Blu-ray filesystems
cec Enable support for HDMI-CEC devices via libcec
css Enable reading of encrypted DVDs
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
dvd Enable optical (CD/DVD drive) support
gbm Use the Graphics Buffer Manager for EGL on KMS.
gles Enable support for GLES
lcms Add lcms support (color management engine)
libusb Use virtual/libusb for usb device hotplug support. This flag should only be enabled if you're running a non-Linux kernel or you don't want to use sys-fs/udev.
lirc Enable support for controlling Totem with a remote control using app-misc/lirc
mariadb Add MariaDB support
mysql Add mySQL Database support
nfs Enable NFS client support
raspberry-pi Enable support for the Raspberry Pi
system-ffmpeg Use system ffmpeg instead of the bundled one
udev Use sys-fs/udev rules to handle devices' permissions and hotplug support. Unless you know what you're doing do not disable this flag on Linux kernels. This is provided as an option for completeness.
upower Enable power management support
vaapi Enable Video Acceleration API for hardware decoding
wayland Enable dev-libs/wayland backend
webserver Enable internal webserver
xslt Enable XSLT support using dev-libs/libxslt

Emerge

root #emerge --ask media-tv/kodi

Configuration

Create user

First create the kodi user:

root #useradd -m -G audio,cdrom,video,cdrw,usb,users kodi

To add support for HDMI CEC:

root #gpasswd --add kodi uucp

Services

OpenRC + xinit

Then define the Kodi init.d file with the following contents:

FILE /etc/init.d/kodi
#!/sbin/openrc-run
# Released under the 2-clause BSD license.

KODI_USER=${KODI_USER:-kodi}
KODI_HOME=$(getent passwd "${KODI_USER%:*}" | cut -d ':' -f 6)

command="/usr/bin/xinit"
command_args="/usr/bin/kodi-standalone ${KODI_OPTS} -- :0"
command_user="${KODI_USER}"
command_background="yes"
description="Start and stop Kodi"
directory="${KODI_HOME}"
name="Kodi"
pidfile="/var/run/kodi.pid"

depend()
{
	need net
}

Set the appropriate permissions:

root #chmod +x /etc/init.d/kodi

And tell OpenRC to start it on boot:

root #rc-update add kodi default

Using inittab

First create the kodi user (see above). This is based on the way the MythTV ebuilds enable the autostart of the MythTV frontend.

Define an .xinitrc file in kodi's home:

FILE /home/kodi/.xinitrc
[ -x /usr/bin/nvidia-settings ] && /usr/bin/nvidia-settings -l
/usr/bin/xset s noblank
/usr/bin/xset s off
/usr/bin/xset -dpms
/usr/bin/evilwm &
exec /usr/bin/kodi

Then create the login scripts:

FILE /home/kodi/.bash_profile
case "`tty`" in
        *tty9) startx; logout ;;
esac

Finally append an inittab entry which does the autologin:

FILE /etc/inittab
# Start Kodi
c9:2345:respawn:/sbin/mingetty --autologin kodi tty9

Gentoo Hardened

Running Kodi on a Hardened Gentoo installation is possible. To avoid grsecurity interfering with network connectivity, the CONFIG_GRKERNSEC_PROC_USER kernel option must not be enabled.

Should you require a restricted /proc filesystem, use CONFIG_GRKERNSEC_PROC_USERGROUP and set GRKERNSEC_PROC_GID to the ID of a group that the user running Kodi is a member of.

Usage

Shutdown

Allow the kodi user to issue an shutdown via polkit, resulting in a shutdown option in the Kodi menu:

FILE /etc/polkit-1/rules.d/60-kodi.rules
polkit.addRule(function(action, subject) {
        if (( (action.id.indexOf("org.freedesktop.udisks.") == 0) || (action.id.indexOf("org.freedesktop.upower.")== 0) || (action.id.indexOf("org.freedesktop.consolekit.")== 0) ) &&
        subject.user=="kodi") {
        return polkit.Result.YES;
        }
});
Note
Ensure the udev USE flag is set for shutdown to work.

External resources