HOW-TO:Install Kodi on an Intel NUC

THIS SECTION IS CURRENTLY UNDER CONSTRUCTION (STARTED 2014.10.03)

Preliminary
The preliminary requirement for this tutorial is, that you have managed for the NUC to be up and booting @least into the bios screen (memory and storage well recognised). Since a NUC comes almost barebone (case and mainboard), memory and harddrive (msata) is mandatory. This means as well, that a keyboard is plugged in and an HDMI connection to a TV/monitor is established.

I recommend a haswell based design, since it is superior to the older models in many respects (IRDA built in). I would assume, that KODI has an appetite for the i5 board, but I have read that the i3 is way sufficient for the day2day use. Don't (!) save too much money - you want the i5 - think about the Aeon MQ5 skin ;_)

So with the shiny bios flashing on your TV/monitor you are ready to go.

ATTN: make sure to always update to the latest BIOS prior to any installation attempt, otherwise you might run into issues during the setup process (missing boot devices, etc.)

Distributions
Before you continue with the native installation method, that I describe later, you should consider either of the pre-built KODI distributions, that already work out of the box on the NUC platform. If you want to go down that road, please refer to the respective sections: KODIbuntu OpenELEC

I myself have started with KODIbuntu (KodiBuntu). The problem is, that the current download image for USB installation is not capable to EFI boot. Therefor it is not possible (!) to install KODIbuntu with propper initial EFI bios support. There are ways to enable EFI boot later, but that is a tricky thing to do. If you wish to go down that road, there is already a very good HOW-TO:Install KodiBuntu from a USB drive

Native Ubuntu & KODI (KODIbuntu do it yourself)
Re-build KODIbuntu from a default Ubuntu image to be able to have Mind you, that AutoStart & HDAudio works already with the original KODIbuntu image.
 * full EFI-Bios support
 * effective AutoStart {xsessions)
 * DTSHD/TrueHD support

Many credits of this tutorial go to the authors of the various resources around the internet, that cover almost all the aspects, that I concentrate here. Please pay some attention to these sites, since they either cover other linux aspects or different solutions as well (like PLEX, etc.).
 * https://forums.plex.tv/index.php/topic/103833-definitive-intel-nuc-how-to-guide-surround-sound-over-hdmi-apple-remote-graphics/

Install Ubuntu Desktop
Initially you want to install a current Desktop Version of Ubuntu (http://www.ubuntu.com/download/desktop). The advantage of the Desktop Version is, that X11 gets already configured for you. With KODI you are *NOT* in a desktop-less server use case. It is of some advantage to be able to log into the Ubuntu-Desktop on demand. So you download the latest Ubuntu Desktop image and basically follow down the same procedure as described in the HOW-TO:Install KodiBuntu from a USB drive (... but with a different image !). Attention:
 * You *HAVE* to boot your USB drive through EFI support. If the drive is not recognised by the EFI-Bios and boots the legacy way, you will not end up with an EFI installation. That can be tricky. It might as well mean the you boot cycle your NUC a view times until the thumbdrive is properly recognised. Even try to unetbootin your thumbdrive again.
 * If you get to the partition section, I would recommend *NOT* to use LVM but opt for a straight forward default configuration. LVM adds some complexity, that you should choose only if you need it (RAID designs, etc.) or you know exactly what you are doing.
 * If you skip any default option during the partion layout: the boot-partion is very important for EFI to work. Choose at least 512MB, FAT32 and mount it to /boot/efi.

Install KODI
Once you have booted into your shiny new desktop for the first time, you now get ready for the KODI installation. So fire up a terminal and follow the steps following the HOW-TO:Install XBMC for Linux.

autostart KODI
If you have followed the Ubuntu Desktop installation above, autostarting KODI is as easy as adding another desktop session to the login xsessions. Ubuntu remebers the last used desktop/xsession. So the new KODI xsession survives the next reboot. cd /usr/share/xsessions vi KODI.desktop Insert the next lines into the newly generated file [Desktop Entry] Name=KODI Comment=This session will start KODI Media Center Exec=KODI-standalone TryExec=KODI-standalone Type=Application In order to be able to choose this new desktop, logout of the ubuntu GUI (upper right corner, logout/exit). This will get you to the ubuntu login-screen. If you click on the symbol just right of your current login, you will be able to choose the new desktop entry. Login, using your predefined user credentials - and you should be beamed right into KODI.

disable PulseAudio
For reference, you find a good KODI/PulseAudio guide here: PulseAudio. While PulseAudio is mandatory in a shared audio use case in a default desktop environment, it simply does not support passthrough of HD-audio (DTS-HD, TrueHD, etc.) at this time. So if you need this, because you have an AV receiver that is able to encode that material, you need to disable PulseAudio during KODI use. You could simply uninstall it, but since it would be need for the ubuntu desktop, there is a handy workaround, that goes hand-in-hand with the KODI autostart method.

There is a convenient command line method to start KODI without loading the PulseAudio environment. Unfortunately we cannot use that method, directly within the xsession profile. In order to force KODI into using the ALSA drivers, we use a script wrapper for the KODI startup instead.

vi ~/KODI_alsa_session_starter AE_SINK=ALSA kodi-standalone chmod +x ~/KODI_alsa_session_starter
 * 1) !/bin/bash
 * 2) force KODI to use ALSA for proper passthrough support

Finally we need to add a new xsession configuration that we can use for autostarting KODI with ALSA support. sudo vi /usr/share/xsessions/KODI_ALSA.desktop You have to modify the config according to your specific username [Desktop Entry] Name=KODI Comment=This session will start KODI Media Center in ALSA mode Exec=/home/**USERNAME**/KODI_alsa_session_starter Type=Application Now "exit" KODI or the Ubuntu desktop and use the "new" xsession KODI_ALSA with your predefined user. You are now using an KODI in ALSA mode.

configure LIRC
I order to be able to use the built in IR receiver follow the HOW-TO:Set up an MCE remote control in Linux