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

Kodi (formerly XBMC) is a media center application.

Upstream project management renamed XBMC to Kodi. When using a version older than 14.0 substitute Kodi for the old name.


USE flags

USE flags for media-tv/kodi Kodi is a free and open source media-player and entertainment hub

X Add support for X11 global
airplay enable AirPlay support local
alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture) global
bluetooth Enable Bluetooth Support global
bluray Enable playback of Blu-ray filesystems local
caps Use Linux capabilities library to control privilege global
cec Enable support for HDMI-CEC devices via libcec local
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc) global
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces global
gles Enable support for GLES local
java Add support for Java global
midi Support MIDI files local
mysql Add mySQL Database support global
nfs Enable NFS client support local
opengl Add support for OpenGL (3D graphics) global
profile Add support for software performance analysis (will likely vary from ebuild to ebuild) global
pulseaudio Add support for PulseAudio sound server global
samba Add support for SAMBA (Windows File and Printer sharing) global
sftp Support browsing files over SFTP local
test Workaround to pull in packages needed to run with FEATURES=test. Portage-2.1.2 handles this internally, so don't set it in make.conf/package.use anymore global
texturepacker Support packing skin textures local
udisks Enable storage management support (automounting, volume monitoring, etc) global
upnp Enable UPnP port mapping support global
upower Enable power management support global
usb Add USB support to applications that have optional USB support (e.g. cups) global
vaapi Enable Video Acceleration API for hardware decoding global
vdpau Enable the Video Decode and Presentation API for Unix acceleration interface global
webserver Enable internal webserver local
zeroconf Support for DNS Service Discovery (DNS-SD) global


root #emerge --ask media-tv/kodi


Create user

First create the kodi user:

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



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

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

description="Start and stop Kodi"

	need net

        ebegin "Starting Kodi"
        start-stop-daemon --start -u ${KODI_USER:-kodi} --background --pidfile /var/run/kodi.pid --make-pidfile --exec /usr/bin/xinit -- /usr/bin/kodi-standalone ${KODI_OPTS} -- :0
        eend $?

        ebegin "Stopping Kodi"
        start-stop-daemon --stop --pidfile /var/run/kodi.pid
        eend $?

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
# .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
# .bash_profile
case "`tty`" in
        *tty9) startx; logout ;;

Finally append an inittab entry which does the autologin:

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

Running on 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.



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 set for shutdown to work.

External resources