Blu-Ray playback with Kodi

I recently upgraded my HTPC’s optical drive to Blu-Ray (primarily for The Force Awakens). The DRM on Blu-Rays is problematic when you’ve built your own player – you can’t just stick the disc in and hit the play button like you can with DVDs. I’m using MakeMKV1 which lets you rip Blu-Rays for encoding with Handbrake, but I don’t really have the storage to be ripping Blu-Rays on an ongoing basis. Fortunately, MakeMKV also allows a disc to be streamed over UPnP, which Kodi supports natively.

To make this a bit more usable, I’m using a script to launch the stream with MakeMKV’s CLI interface, wait until the UPnP share is ready, then switch Kodi to the share ready to select the title from the disc.

I’m using the Advanced Launcher addon for Kodi to create a launcher for I’ve created a Favourite for the launcher and added it to the main menu. Now the process is:

  • Insert disc
  • Activate launcher
  • Wait until it’s ready
  • Select title and watch
  1. MakeMKV is proprietary, but free-as-in-beer as it’s in “perpetual beta”. You do however need to keep updating the beta registration code, so I paid for a license as I want this to be “setup and forget”.

Setting up a Steam Controller on Ubuntu

I recently received my pre-ordered Steam Controller, which I’ve be itching to use with my home-built HTPC/Steam Machine.  I do all my gaming (and everything else) on Ubuntu, and discovered at that the time the pre-releases were shipped, there was a bit of tweaking to do to get the controller working.  Thanks go to this Ask Ubuntu question and this Steam Community thread.  If you are using Ubuntu 15.10 or later, steps 1-3 shouldn’t be necessary, and hopefully a fix will be in place by the time the controllers are on general sale.

  1. Before you plug in your controller, edit (or create) file /lib/udev/rules.d/99-steam-controller-perms.rules.  This already existed on my system.  Edit to to contain at least these lines (it may also contain others):
    SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666" 
    KERNEL=="uinput", MODE="0660", GROUP="yourusernamehere", OPTIONS+="static_node=uinput"

    Make sure you change “yourusernamehere” to the user you run steam as, or if there are several, the name of a group containing them all.  This will ensure that the controller is correctly recognised and can emulate a gamepad.

  2. Run sudo apt-get install python3-autopilot.  This will install some packages which will add you to a group with write access to /dev/uinput.  This is necessary for the controller to work properly.
  3. Reboot
  4. Plug in your steam controller dongle.
  5. Press the Steam button. It should beep and light up (if not, check the batteries are installed).
  6. Launch Steam.  You should see a notification that your controller is detected.
  7. Launch Big Picture Mode (if you don’t, Steam will tell you to).
  8. Ensure the Steam overlay is enabled in Settings -> In-game.  If not, your controller configurations will simply not work.
  9. Select a game, pick a controller configuration, and play!

My Steam Box – PVR power management

Update: Updated post-record bash script for Ubuntu 16.04, and re-wrote ruby script to use HTTP instead of Telnet.

I mentioned before that I’m using tvheadend and XBMC as a PVR on my Steam box/HTPC. This allows me to schedule recordings and do things like series link recordings to ensure I dont miss an episode. However, it does have the slight disadvantage that I need to leave a full-power PC on all the time, otherwise it can’t record. I needed a smarter solution for the sake of my electricity bill, so I devised a way to have the PC turn on when a recording is scheduled, do the recording, then power off again when its done.

Power on to record

My first discovery when hunting for a solution was the ACPI wake alarm feature. This allows you to set an alarm on your hardware clock at which point the computer will turn itself on, even if it’s completely powered off, just as though you’d pressed the power button.

There’s a couple of steps I needed to enable this feature, found thanks to the MythTV wiki. Firstly, it needed to be enabled in the BIOS/UEFI. The setting for my motherboard was called something like “Hardware Clock Wake Up”. Secondly, Ubuntu’s shutdown scripts overwrite the hardware clock with the current time, erasing any alarm set, so a small modification to /etc/init/hwclock-save.conf was required. This ensures that the alarm is written back to the hardware clock.

With the feature enabled, I then needed a command to set the alarm. XBMC’s TV settings have a “Power Saving” section, with a “Set wakeup command” option. This lets you give a command which will be called with the unix timestamp of the next recording as an argument. I set this to sudo /home/xbmc/ I used sudo since I needed permission to write to the wakealarm device, and added a sudoers rule to let XBMC run the command without a password:
xbmc ALL=NOPASSWD: /home/xbmc/

Finally, the script itself:

The business is all on lines 4 and 5. 4 clears any previous alarms, and 5 sets a new one using the passed timestamp. XBMC has a “Wakeup before recording” option which lets you adjust the timestamp arugment to be a few minutes ahead of the actual record time. This script is triggered whenever XBMC is shut down.

Power off after recording

Powering off was a bit of a trickier business. Tvheadend has a “Post-processor command” setting which executes after a recording completes, which is simple enough. However, just putting shutdown -h now in there isn’t enough, since it wont cause XBMC to call its wakeup script, meaning the next recording could be missed. XBMC’s shutdown or exit command has to be called explicitly for this to happen. Furthermore, I didn’t always want the system to turn off – what if I was watching something, or playing a game at the time?

After some poking around, I found that using the shutdown button in XBMC’s web interface was sufficient to trigger the wakeup script. Furthermore, this was using XBMC’s JSONRPC interface, which could be fed commands by sending raw JSON strings over telnet. This gave me a way of triggering the shutdown and wakeup from a script, with the added bonus of giving me a way to find out if XBMC was currently playing something. This led to the creating of this ruby script and a bash script to call it:

The bash script is the command actually called by tvheadend, which calls the ruby script. The ruby script checks that no other users are logged in, no video is playing in XBMC, then calls XBMC’s shut down routine, which in turn sets the alarm for the next recording. Job done!

My Steam Box – Amazon Instant Video on Ubuntu

While my Steam Box is running XBMC for media playback, there’s one service I use which XBMC can’t provide: Amazon Instant Video (formerly Lovefilm Instant).

AIV can be streamed through various apps or through Silverlight in a web browser. However, none of these options are supported on desktop Linux.  Of course, with the Ubuntu ecosystem being what it is, “not supported” is far from “impossible”.

The solution to the problem comes in the form of Pipelight – a browser plugin for Firefox which runs Silverlight and other Windows-only browser plugins in a special version of Wine.  This clever little hack (installed from a PPA through apt-get) allows you to watch Silverlight content within Firefox for Linux! It’s worth noting that I use the pipelight-multi package which allows you to set up Pipelight and Pipelight’s WINE installation for specific users, rather than for every user on the system.

With this problem solved, I wanted to make the user experience of accessing AIV a bit smoother.  To acheive this, I created a small autorun script which runs when the lovefilm user logs in to openbox.  The script contains the following commands:

switch-to-xbmc &
pkill -u lovefilm

This means that firefox launches on login. Firefox is configured to open AIV when it starts, and to run in fullscreen mode, has all but a few toolbar buttons removed and consolidated into a single toolbar. When we’re done watching, we close firefox, which lets switch-to-xbmc execute to return us to the XBMC menu, then pkill kills any other processes belonging to the lovefilm user, logging it out.

The final issue with using AIV on a TV is that the web page is noisy and not designed to be used on a big screen on the other side of the room. To fix this I’ve written a GreaseMonkey userscript (very much a work-in-progress) to remove a lot of the Amazon bumf and reformat the page to make it work better on a large screen.

My next and final post in this series will look at how I’ve got Steam and some associated utilities set up.

My Steam Box – Media Playback

For media playback on my Steam Box/HTPC I’m (mostly) using XBMC.  This lets me play videos from my server and watch DVDs from my DVD drive.  On top of this basic functionality I’ve installed the BBC iPlayer and YouTube plugins to allow me to stream content from the web.


I mentioned in my hardware post that I’d purchased a DVB-T2 USB dongle to allow me to watch HD TV.  For the past several years, the standard solution for TV/PVR functionality on Linux has been MythTV.  However, these days XBMC also has a good deal of this functionality in its PVR plugins, as long as you can get a backend service installed to operate the tuner.

One of these options is, of course, MythTV Backend. However, after struggling through the “Setup Wizard” being asked every question under the sun and still not getting it working, I gave up and found TVHeadEnd.  This gives you a simple web interface which detects your hardware and scans for channels with ease.  Adding the TVHeadEnd PVR plugin to XBMC gave me live TV and PVR functionality with minimum fuss.


XBMC gives you several remote control options, including a web interface and a service for other remote control apps to connect to.  I have a remote control widget on my android phone which works well enough, but I’ve found it easiest just to use the regular keys on my Rii Touch keyboard.


I’m not a particular fan of XBMC’s default Confluence theme, in particular it’s menu which only shows the selected option.  After looking around and finding this guide on Lifehacker, I switched to the Transparency theme which has a much better menu, and could be customised to have just the bits I need.

Switching Users

I mentioned in my last post that I’d written scripts using dm-tool to switch between users.  To run these from XBMC I installed the Advanced Launcher addon. This addon lets you create launchers for any executable within XBMC, and add them to the main menu in themes that support it.  Using this method I created launchers for the switch-to-steam and switch-to-lovefilm scripts on the main menu.

My Steam Box – OS and Software

In my last post I went over the hardware I used for my new Steam Box/HTPC all-in-one living room PC.  In this post I’m going to go over how I’ve got the OS set up and touch on the software I’m running to provide me with gaming and media playing functions.  I’ll then go over the details of each function in separate posts.

To start with, I did a vanilla Ubuntu 12.04 LTS desktop install.  I’d considered going for SteamOS, but to be honest, Big Picture Mode isn’t quite there yet, and I know where I am when it comes to getting extra packages and cool hacks for Ubuntu.  One part of SteamOS I was really impressed with is how they’ve set up Steam and the desktop session on separate profiles letting you can switch easily between the two functions, so I chose to emulate that on my set up.

The 3 main functions I wanted were media playback, a basic desktop (mainly for administrative tasks) and a desktop session to run Steam.

For administrative functions, I created a user called “mark” during installation (as I usually do).  Mark is a sudoer, with a standard 12.04 Unity desktop.

For media playback, I installed XBMC.  I created an unprivileged user called “xbmc”, set to auto-login to the XBMC standalone session with no password, making XBMC the initial interface on boot.

For gaming, I created a second unprivileged user called “steam”, set to log in to a Unity desktop session with no password.  Steam is set to auto run on log in, and display the Library tab in Grid view (showing the artwork for each game like Big Picture Mode does).

There’s also a third unprivileged user called “lovefilm” which logs in to an openbox session with no password, but I’ll talk about that more in its own post.

To switch to each user, I’ve created a scripts called “switch-to-xbmc” etc. which use the dm-tool utility.  These can be called from the appropriate interface (a menu item in XBMC, a non-Steam application launcher in Steam) to quickly switch to between users.

In the next post I’ll talk about how I’ve set up XBMC for media playback in a bit more detail.

My Steam Box – Hardware

Having played with SteamOS for my last post, I decided that it would be a lot more fun if my gaming PC, rather than being in my spare room connected to a small screen, was in my living room attached to my big TV.  In addition to this, I had several devices under my PC to provide me with various media-viewing functions (streaming services, DVD playback, TV), which was a pain and took up a lot of room.  To this end, I elected to build a box which could do all these jobs in one.  I’ve now got the box in a “stable” enough state that I thought it time to write about it, starting this post with the hardware.


I started the build by cannibalising the insides of my existing gaming PC, which I’d upgraded not long ago.  This gave me a starting point of an AMD A8 APU (quad-core with integrated 3D accelerated graphics), 8GB of RAM, a motherboard along the lines of this one, and a 240GB SSD.

It also gave me a very noisy heatsink. This was a problem as a box sitting under my TV needs to be quiet. After some research I bought a Zalman CPNS8900 Quiet heatsink, which does a great job of cooling with minimal noise and a low profile, but takes up a lot of horizontal room around the processor. So much, in fact, it lent against one of the RAM DIMMs.

To solve this problem along with screen limited resolution due to my TV’s poor VGA support, I upgraded my motherboard to An AsRock FM2A88M Extreme 4+ which had 3 key features: the FM2 socket for the processor, an HDMI port to ease connection to the TV, and 4 RAM Slots, meaning I could move the 2 DIMMs away from the processor allowing room for the heatsink. As an added bonus, the stock heatsink mount was screwed on rather than using plastic toggle bolts at the old one had, making mounting the Zalman much easier than it had been as I could just screw it onto the existing back plate.

The final piece of the puzzle was a power supply. Again, I wanted something quiet so went for a Corsair CM430M which is 80+% efficient and has a 120mm fan. It’s also modular, meaning only the required cables need to be attached, so reducing cable management needs inside the case.

Photo showing the inside of the steam box from above.

Obligatory internal shot, taken from above. The big power supply in the bottom right draws air from vents in the underside of the case and straight out the back, while the big heatsink on the left draws air in through vents above and out through vents in the side and back. Note the RAM slot nearest the heatsink is obstructed. Top-right is a short-depth DVD drive, with the SSD mounted underneath.


When building a PC you can basically pick 2 qualities from powerful, small, and quiet. My main concerns for this machine were power (for gaming) and quietness, meaning I’d inevitably be building something fairly big.  I plumped for a SilverStone ML03B – a half-height MicroATX case which isn’t the most beautiful case, but is really well designed and fits everything inside nicely. I’ve written a full review here.

Photo showing the front of the Silverstone case, with a DVD drive and Gamecube USB adaptor installed.

The completed steam box viewed from the front, with Gamecube USB adapter on top.


I’ve always been a big fan on Nintendo controllers, I’ve still got a few Gamecube controllers as well as a couple of Wii Remotes.  With the launch of Steam’s Big Picture Mode, Valve are encouraging games developers to make their games with well with gamepads.  For those games, I use a Gamecube controller via this USB adapter (found via the Dolphin Emulator site).  I’ve owned several Gamecube-USB adapters, but this one is particularly good, firstly because it has 2 inputs, and secondly because it’s the only adapter I’ve found which works with Wavebird wireless controllers.

For games designed to be used with a mouse cursor, I connect a Wii Remote using a bluetooth dongle and a USB-powered sensor bar.

I also needed a keyboard and mouse that I could use from across the room.  There’s some nice IR remotes out there, but I went for the easy option and got a Rii Touch handheld keyboard with built-in touchpad.  I initially bought a bluetooth model but bluetooth connectivity requires pairing the device and the OS to boot before it can connect, which wasn’t terribly smooth.  I ended up with the  proprietary RF version which connects as long as the USB port has power, and just appears as a regular wired keyboard and touch pad to the OS.  It’s not perfect perfect but I’d give it 9/10 as a solution.


While my TV has Freeview built in, I didn’t have a way to watch live HD channels.  To enable this I bought a PCTV nanoStick T2, a USB DVB-T2 (Freeview HD) dongle.  Notably, this is the only USB DVB-T2 tuner which has support in the Linux kernel at the time of writing, so it Just Works with no additional drivers needed.


That’s all for the hardware at the moment. In my next post I’ll look at how I’ve set up the OS and Steam.