Month: August 2019

Raspberry Pi 4, Kodi, and Chrome – An Uncomfortable Alliance

For years, I have needed two devices in order to watch quality drinking-time programming in my bedroom:

  • A Chromebit, which runs Chromium, for those late-night binges of TVTropes.orgbut doesn’t run Kodi
  • A Nexus Player, which runs Kodi, among other things but doesn’t run Chromium
  • Two remotes and an HDMI switcher to make it work

Each component is fantastic at what it does – the Nexus Player, despite being largely mothballed, has a great interface, and the Chromebit is the easiest way to get Chrome on HDMI – but it sucks for the need to use two devices.

This summer, I decided to fix that mess.

What follows is a short list of things I tried, none of which could pull it off:

  • Raspberry Pi 3 running Kodi (too underpowered)
  • Raspberry Pi 3 running Emteria OS (see above)
  • Essential Phone running Android TV Launcher (mobile browser on a big screen is a wreck)
  • Raspberry Pi 4 running Emteria OS (not until Emteria releases a build for the Pi 4; I couldn’t properly hijack the Pi 3 build

Here’s what worked:

Here’s how to do it.

Step 1: Download and Install Raspbian

  1. Download Raspbian Buster. I wanted to customize my GUI, so I went with the Lite ISO, but ain’t nothing wrong with the Desktop version.
  2. Flash the image to your MicroSD card using your favorite flashing software. (I’m on Manjaro, so this meant BalenaEtcher, but Rufus is great for Windows.)
  3. If you’re on WiFi, you’ll need to connect. This is trivial if you downloaded Raspbian Desktop, since it happens on boot. If you’re using Raspbian lite, enter sudo raspi-config and choose Networking Options. Enter the SSID and password.
  4. Enable SSH. If you’re using Raspbian Desktop, then open a terminal window (if you’re using Lite, you’re already at one). Enter sudo raspi-config, choose Interface Options | SSH and enable.
  5. Reboot to make sure the change stuck. You can tell if the WiFi setup worked by typing ip address to confirm that you have a proper IP, and you can confirm that SSH is installed by ssh’ing into said IP.

Step 1b: Install a Desktop Environment

If you used Raspbian Lite, you’ll need to install a desktop environment. Everybody has their favorite and I’m not going to take that away from you. I went with XFCE because it has rather beefy window icons and ready support for changes to DPI. Both will be important since I’m watching this on a projector and navigating from my bed, so usability is paramount.

To install, just type sudo apt install xfce4 and let the magic – and about a million dependencies – happen.

I would also recommend sudo apt install network-manager-gnome. This could be unnecessary, but I found it stopped having the WiFi stop working after the first or second reboot. Admonish in the comments if this is unnecessary.

Step 2: Install Kodi and Chromium

Straightforward enough:
sudo apt install kodi chromium-browser seahorse

Kodi has the ability of starting as its own desktop environment. We will eschew this option, since the only advantage of doing so is that you don’t see the Applications bar when you hover over it. Meanwhile, the disadvantage is that you can’t run any other Gnome apps, which is irritating.

Step 3: Log into XFCE, make it the default, and suppress them password dialogs

Reboot (sudo reboot), and when logging in, make sure that XFCE4 is selected as your desktop environment (top-right corner). Logging in is annoying, so we will invoke auto-login.

Similarly, when opening Chromium, entering a password for the default keyring is a pain, so we will suppress it.

Both of these moves are strongly advised against by StackExchange pedants, and that’s fair enough. But this is a media center, not the NSA, and convenience is paramount. Further, we’re going to change the pi’s password so there’s at least one layer of security still present.

  1. Open a terminal window by clicking Applications | System | XTerm. Type passwd and follow the instructions to change the default password from raspberry to something else.
  2. Run sudo raspi-config to configure auto-login: Select Boot Options | Desktop / CLI | Desktop Autologin and then Finish.
  3. Exit the terminal. Open Seahorse password manager by clicking Applications | Accessories | Passwords and Keys
  4. Right-click on Login and choose Change Password. Change the password to <blank>. This will disable prompts to unlock the default keyring.

Step 3b: Optionally, Configure HiDPI Mode

Tiny buttons are hard to hit with a remote control, and tiny text is hard to read when projected across the room. The easiest way to uniformly scale everything on screen is to adjust the DPI settings. This is optional and depends on your use case.

  1. Open Applications | Settings | Appearance and under Fonts change the DPI to 120 – or whatever works for you.
  2. Open Applications | Settings | Window Manager and under Style select Default-hdpi
  3. Reboot to see the full effects.

Step 4: Configure Advanced Launcher

Advanced Launcher is a Kodi addon that creates icons for ordinary apps. We’ll use this, plus a shell script, to launch Chromium from within Kodi

  1. SSH into your pi
  2. Download Advanced Launcher by typing
    wget https://github.com/SpiralCut/plugin.program.advanced.launcher/archive/master.zip
  3. Type nano chromium.sh and enter the following file contents:
    #! /bin/bash
    chromium-browser --user-agent="Mozilla/5.0 (X11; CrOS armv7l 10895.56.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.102 Safari/537.36" --window-size=1920,1080 $1
  4. Return to the pi and open Kodi. Install Advanced Launcher.
  5. Navigate to Add-ons | Add-On Browser (the open box at the top next to the Settings gear)
  6. Choose Install from Zip file and navigate to Home Folder and select master.zip. You’ll likely have to answer a prompt to enable unknown sources.
  7. Advanced Launcher should now be under Program Addons in your Addons folder. Open it and navigate to Default. A dialog to create a new launcher should appear.
    1. Choose Standalone Launcher. Navigate to Home Folder and choose chromium.sh
    2. Leave arguments blank
    3. Keep the title as Chromium – or change it. Free country.
    4. Select Linux as the platform
    5. Skip Thumbnails and Fanart
  8. You now have a launcher that invokes Chromium from within Kodi. To make it more accessible, right-click on the launcher and choose Add to Favourites.

Step 5: Have a lovely beverage

There are additional steps if you want to use Netflix, Amazon Prime, or (heaven help you) Xfinity. But, at this point, you have a nice core setup, so lean back with a lovely beverage and celebrate your accomplishments. The rest can wait for later posts.

Posted by Adam Labay, 0 comments