Saturday, April 18, 2020

Raspberry Pi HTPC and Streaming Machine

Introduction

I like to sit on couch in my living room and watch my media or play my games from my 4k flat screen TV. I like to do this all while using an Xbox 360 controller to navigate menus and play games. 
I will be using a Raspberry Pi 3b to Create a Home Theater PC that can be controlled using an xbox 360 controller, or any other controller you want.

The Raspberry Pi Setup

The setup of the Raspberry Pi is quite simple. We will start with a clean image of Raspbian followed by installing all the required software and finally configuring the front end.

Tools Used:

  • Raspberry Pi 3b
  • 8 gb micro SD card

Software Used:

  • Raspbian Desktop (Buster)
  • RetroPie
  • EmulationStation
  • Steamlink
  • Parsec
  • Kodi

Installing Raspbian

Download the Raspbian image from the official Raspberry Pi website (https://www.raspberrypi.org/downloads/raspbian/). The image I used was Buster.

After installation is completed, run the raspi-config command and set the video shared memory to 128.

Installing RetroPie

Installing RetroPie is actually simple. From your Raspberry Pi terminal, type in the following commands,

sudo apt-get update -y
sudo apt-get upgrade -y
sudo update-locale LANG="en_US.UTF-8"
sudo update-locale LANGUAGE="en_US:ne"
sudo update-locale LC_ALL="en_US.UTF-8"

Now Reboot the system to have the loacle changes take effect. After reboot, open up a terminal and type in the following commands,

sudo apt-get install -y git lsb-release
cd ~
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup
chmod +x retropie_setup.sh
sudo ./retropie_setup.sh

Run the Basic Install.

Follow these instructions to setup auto start on boot, https://retropie.org.uk/docs/FAQ/#how-do-i-boot-to-the-desktop-or-kodi

Installing Steamlink

To install Steamlink, open a terminal in on your Raspberry Pi and type in the following command,

sudo apt install steamlink

Installing Parsec

To install Parsec, open up a terminal on your Raspberry Pi and ty[pe in the following command,


wget https://s3.amazonaws.com/parsec-build/package/parsec-rpi.debsudo dpkg -i parsec-rpi.deb

Installing Kodi

To install Kodi, open up a terminal on your Raspberry Pi and type in the following command,

sudo apt-get install kodi

Configuring EmulationStation

Now we need to configure the EmulationStation with a "System" that we can launch our Steamlink, Kodi, and Parsec from and then add some scripts to launch our streaming apps.

Create the Streaming System

To do this we will open up a file on your Raspberry Pi and add some XML to create our new System. Open up the file

~/.emulationstation/es_systems.cfg

and add the following XML lines,

<system>
  <name>Streaming</name>
  <fullname>Streaming Apps</name>
</system>

save the file and we are done with the configuration of EmulationStation.

Creating launch scripts

Now we will create the launch scripts for each of our streaming apps. Create the following executable files by using this command,

mkdir -p ~/RetroPie/roms/streaming
touch ~/RetroPie/roms/streaming/steamlink.sh
touch ~/RetroPie/roms/streaming/kodi.sh
touch ~/RetroPie/roms/streaming/parsec.sh
chmod +x ~/RetroPie/roms/streaming/steamlink.sh
chmod +x ~/RetroPie/roms/streaming/kodi.sh
chmod +x ~/RetroPie/roms/streaming/parsec.sh

Now open each of the files and add the following lines, first is for steamlink.sh

#!/bin/bash
pushd
steamlink
popd

next is kodi.sh

#!/bin/bash
pushd
kodi
popd

and lastly, parsec.sh

#!/bin/bash
pushd
parsecd
popd

After you have rebooted your Raspberry Pi it will now boot up into the EmulationStation front end with a System called Streaming. You will now be able to launch SteamLink, Kodi or Parsec from the comfort of your couch!

Configuring Kodi

There are a couple things we need to do to make Kodi more couch friendly. First thing is to allow for remote HTTP... coming soon.

TODO:

I still have to configure to my xbox 360 controller to work with Kodi.