Skip to content

Instantly share code, notes, and snippets.

@SierraNL
Last active September 15, 2021 20:31
Show Gist options
  • Save SierraNL/8837b787bb0905a709d0 to your computer and use it in GitHub Desktop.
Save SierraNL/8837b787bb0905a709d0 to your computer and use it in GitHub Desktop.
Intel NUC DN2820FYKH: KodiBuntu, Netflix through ChromeLauncher, Steam (in-home streaming), PS3 Sixaxis (DS) controllers

##Introduction

This is basicly a note to self, on how I setup my NUC. But I like to share it, since there is no complete step-by-step tutorial that combines all these features.

This Gist is based on tons of tutorials and forumposts, which I will try to mention all in this list:

##Assumptions I performed these steps on a NUC with the 2820 cpu, not the 2830 one, with a ** BIOS. My NUC has 4GB ram and a 64GB SSD.

It's all 14.2 Kodi Helix and based on Ubuntu 14.04.1 LTS Trusty.

I'll try to update the guide when Kodi 15 Isengard is stable.

##Steps

###NUC BIOS

  • Update your NUC to at least version XX

###Create a Kodibuntu USB stick

###Kodibuntu install

  • Kodibuntu install.. next next finish

###Kodi setup Getting addons from default library:

  • Autosub
  • Opensubtitles
  • Apple trailers
  • Uitzendinggemist (NPO)
  • Youtube
  • Rom Collection Browser

Getting extra addon repo's

Install these by downloading these zips and dropping them in the \yournuchostname\downloads folder and select them by installing addons from a zip (the share is in the homedir)

###PS3 Sixaxis controller setup Add the qtsixa ppa which contains an updated version of sixad

sudo apt-add-repository ppa:falk-t-j/qtsixa

Update and install the sixad package.

 sudo apt-get update
 sudo apt-get install sixad

Connect your ps3 controller to your computer via usb and run:

sudo sixpair

Unplug your ps3 controller from the usb cable and run:

sixad --start

When prompted, press the PS button on the controller. If it's detected correctly, the controller will blink and or vibrate. And to make it start on boot (check if this is really needed)

sixad --boot-yes

###Steam setup To configure KODIbuntu to boot to a light weight Openbox session, which is needed for Steam (Kodi runs without a windowmanager)

sudo apt-get install wmctrl

Install the Steam client

wget http://media.steampowered.com/client/installer/steam.deb && sudo dpkg -i steam.deb

Set Openbox as default XSession

sudo cp /usr/share/xsessions/hidden/openbox.desktop /usr/share/xsessions/
sudo dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetXSession string:openbox

Set the Openbox background to black and Kodi to auto start:

mkdir -p $HOME/.config/openbox/ && echo "export DISPLAY=:0" >> $HOME/.config/openbox/autostart.sh && echo "xsetroot -solid black &" >> $HOME/.config/openbox/autostart.sh && echo "/usr/bin/kodi &" >> $HOME/.config/openbox/autostart.sh && chmod +x $HOME/.config/openbox/autostart.sh

For a better Openbox right click menu that contains entries for Steam, Steam BPM, Kodi, Chromium and others:

sudo apt-get install menu
nano ~/.config/openbox/menu.xml
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Openbox 3">
  <item label="Terminal">
    <action name="Execute"><execute>x-terminal-emulator</execute></action>
  </item>
  <item label="Chromium">
    <action name="Execute"><execute>chromium-browser</execute></action>
  </item>
  <item label="PCManFM">
    <action name="Execute"><execute>dbus-launch pcmanfm</execute></action>
  </item>
<item label="Kodi">
    <action name="Execute"><execute>kodi</execute></action>
  </item>
  <item label="Steam">
    <action name="Execute"><execute>steam</execute></action>
  </item>
  <item label="Steam BPM">
    <action name="Execute"><execute>~/.config/openbox/steam-bpm.sh</execute></action>
  </item>
  <!-- This requires the presence of the 'menu' package to work -->
  <menu id="/Debian" />
  <separator />
<item label="Reboot">
    <action name="Execute">
        <prompt>Are you sure you want to reboot?</prompt>
<execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart</execute>                                                                                                                                              
    </action>                                                                                                                                                  
</item>                                                                                                                                                        
                                                                                                                                                                
<item label="Shutdown">                                                                                                                                         
    <action name="Execute">                                                                                                                                     
        <prompt>Are you sure you want to shutdown?</prompt>                                                                                                                                              
        <execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop</execute>
    </action>
</item>

<item label="Suspend">                                                         
    <action name="Execute">                                                     
        <prompt>Are you sure you want to suspend?</prompt>                     
        <execute>dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Suspend</execute>
    </action>
</item>

<item label="Log Out">
    <action name="Execute">
      <prompt>Are you sure you want to log-out?</prompt>
        <execute>openbox --exit</execute>
    </action>
  </item>
</menu>

</openbox_menu>

Create a script to launch Steam BPM, it needs a different command if steam is already running:

nano ~/.config/openbox/steam-bpm.sh && chmod +x ~/.config/openbox/steam-bpm.sh

and paste in the following:

#!/bin/bash

if [[ $(pidof steam) ]] ; then
    steam steam://open/bigpicture
else
    steam -bigpicture
fi

####VAAPI Intel Drivers

wget http://ftp.ubuntu.com/ubuntu/pool/universe/i/intel-vaapi-driver/i965-va-driver_1.3.2-1_amd64.deb
wget http://ftp.ubuntu.com/ubuntu/pool/universe/libv/libva/libva1_1.3.1-3_amd64.deb
sudo dpkg -i libva1_1.3.1-3_amd64.deb
sudo dpkg -i i965-va-driver_1.3.2-1_amd64.deb

You can check with vainfo if the versions of the drivers are correct, 1.3.2 for i965 driver and 1.3.1 for libva

Pulseaudio

This only needs to run when Steam is running, but not when Kodi is running

By default Pulseaudio won't install on KodiBuntu (because Kodi likes Alsa), this fixes that

sudo mv /etc/apt/preferences.d/libasound2-plugins.pref /etc/apt/preferences.d/libasound2-plugins.pref.bak && sudo mv /etc/apt/preferences.d/pulseaudio.pref /etc/apt/preferences.d/pulseaudio.pref.bak

Now install it

sudo apt-get install pulseaudio

Stop Pulseaudio from autostarting

sudo nano /etc/pulse/client.conf

Add at the bottom of the file:

autospawn = no
daemon-binary = /bin/true

Create pre and post scripts for Steamlauncher to stop and start Pulseaudio and Irxevent

nano pre-steam.sh
#!/bin/bash
#change the KILL_KODI_BEFORE_STARTING_PULSEAUDIO= to yes if you want to stop Kodi before starting pulseaudio
#killing Kodi before starting pulseaudio will ensure the steam bpm gui has sound but will reduce the seamlessness of the addon

KILL_KODI_BEFORE_STARTING_PULSEAUDIO=yes

if [[ $KILL_KODI_BEFORE_STARTING_PULSEAUDIO = yes ]] ; then
  kill -9 $(pidof kodi.bin)
fi
sleep 3
pulseaudio --start
if [[ ! $(pidof irxevent) ]]; then
    irxevent -d /home/youruser/steam.lirc
fi
chmod +x pre-steam.sh
nano post-steam.sh
#!/bin/bash
#change the ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI= to yes if you want to stop pulseaudio before starting Kodi
#killing pulseaudio before starting Kodi will ensure that Kodi always uses alsa, but steam may not like having pulseaudio stopped while steam$

ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI=yes

if [[ $ALWAYS_KILL_PULSEAUDIO_BEFORE_STARTING_KODI = yes ]] ; then
  pulseaudio -k
fi

#change the KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM= to no if you dont want to stop pulseaudio only when completely exiting steam
#if yes Kodi will use pulseaudio when steam is running (via 'exit to desktop')
#change the SECONDS_TO_WAIT= to alter the time to wait after closing BPM to check if steam is still running, 2 seconds is good for my system $

KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM=no
SECONDS_TO_WAIT=2

if [[ $KILL_PULSEAUDIO_ONLY_WHEN_COMPLETELY_EXITING_STEAM = yes ]] ; then
  sleep $SECONDS_TO_WAIT
  if [[ ! $(pidof steam) ]] ; then
    pulseaudio -k
  fi
fi

if [[  $(pidof irxevent) ]]; then
    kill $(pidof irxevent)
fi
chmod +x post-steam.sh

####Get your MCE remote working in Steam using irxevent

Install lirc-x which contains irxevent

sudo apt-get install lirc-x

Create a lirc config

nano steam.lirc
###irxevent
begin
prog = irxevent
button = KEY_UP
repeat = 0
config = Key Up CurrentWindow
end

begin
prog = irxevent
button = KEY_DOWN
repeat = 0
config = Key Down CurrentWindow
end

begin
prog = irxevent
button = KEY_LEFT
repeat = 0
config = Key Left CurrentWindow
end

begin
prog = irxevent
button = KEY_RIGHT
repeat = 0
config = Key Right CurrentWindow
end

begin
prog = irxevent
button = KEY_OK
config = Key Return CurrentWindow
repeat = 0
end

begin
prog = irxevent
button = KEY_ENTER
config = Key Return CurrentWindow
repeat = 0
end

####Kodi addons Install Steam launcher addon

Configure the pre and post scripts

Start it once, Steam will begin to install additional packages and update itself.

Then Steam crashes on some missing driver. Run the following command to fix that.

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib

Doing this first doesn't work!

###Netflix using Chrome I've put this after Steam since this needs Kodi running in a windowmanager else you will get Chrome on half the screen

####packages Install Chrome

Add Key:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 

Set repository:

sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

Install package:

sudo apt-get update 
sudo apt-get install google-chrome-stable

####kodi addons Install Chromelauncher

Configure the pre and post scripts

##Conclusion

And now you have a 10Watt NUC which plays all media, netflix, streams games, runs old games using PS3 sixaxis (dualshock) controllers.

###Retroarch (TODO: doesn't work yet)

####packages Install Retroarch / libretro

sudo add-apt-repository ppa:libretro/stable
sudo apt-get update
sudo apt-get install retroarch retroarch-* libretro-*

####kodi addons Configure Rom Collection Browser to use retroarch

##TODOs

  • Retroarch with mame, nes and snes emu's with sound and (multiple) sixaxis controllers.
  • Shutdown the NUC using IR remote (test if the kodi setting works)
  • Describe settings for Kodi and all the addons
  • Steam streaming doesn't always work "Client could not connect to the remote machine" (seems to be fixed running steam on host as admin)
  • Enable joystick support for X, to use Sixaxis in Chrome as a mouse for Netflix (possible solution xboxdrv: xboxdrv/xboxdrv#54)
  • Try lircm to get the remote to function as a mouse in Chrome.
  • add profile to sixad to disable the gyro axis
@kuraimistral
Copy link

@talondnb i just tried this on my D34010WYK. So far it works. far better then steam os with kodi. For the VAAPI Intel Drivers i used the newer ones, since the one in this guide are no longer available.

my only problem is now that I have no sound when I stream games from my Windows PC or start games directly from the NUC on steam.

@kuraimistral
Copy link

Found the culprit. Forgot to add my user in pre-stream.sh. Now everything works!

@bjquinn
Copy link

bjquinn commented Jun 5, 2016

Hey, did you ever get this updated for Kodi 15? I may just try it if not, this is at least a great starting point! Also, I'm sure most of these instructions would work for any hardware, but conveniently I have the exact same NUC you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment