100% plant-based blog.

Roll your own "Kodi"

Context

But why?

Mainly, because it's both easy to do (provided you know how to install Linux and can handle CLI and editing some configs) and easy to get the result you want. Having used the actual Kodi, my take is that 80% of the functionality just works, 10% is difficult to get working as one might want, and 10% is just not possible to fix. And sometimes the thing that is broken might be the Twitch-plugin, and maybe Twitch is what you wanted to watch - so then that 10% actually becomes 100%.

But maybe still not?

Indeed, while my box works more or less flawlessly now, I did have multiple minor issues while setting it up. So let's say that it might take you a few hours longer than you might at first anticipate. Also, we will be using the ranger file manager as our UI - while a great piece of software, and easily color-themable through terminal configuration, it's not going to have the same kind of flying space cube visuals that some dedicated media center softwares might have, because, you know, it is a file manager.

But, if you want a fast and effective way to get to your media, then this might be for you.

Hardware

Required hardware

1. A machine suitable to run a media center. I used Minisforum GK41.

Get something that fits your budget and doesn't ruin the feng shui of your living room. Note that I used an x86_64 machine. I see no (strong) reason why you couldn't do this on ARM, but be advised that software/driver availability for ARM-based operating systems may differ and YMMV.

2. A programmable USB IR receiver. I used Flirc USB.

This is key. Back when I had an actual Kodi box that ran Kodi, I still used flirc, as it's much more user-friendly to operate your TV (system) with a remote with physical buttons that you can comfortably use without looking. Here, though, it's essential, since the actual Kodi remote app obviously won't work with our adaptation of "Kodi".

3. Any old remote

This is, of course, also essential, but given that the flirc is programmable, it should be an easy requirement to fulfill. Ask your parents or neighbors for an old remote if you don't have any. If you manage to find a remote that has arrow keys and 'enter', it will go a long way in terms of making your system intuitive to use. Else you have to mark the keys mentally (or perhaps with a marker).

Additional hardware

4. (optional) A NAS

If you want shared and/or extra storage. I've built my own. The Minisforum box I got offers options for NVMe drive sizes, up to 1T, so this is not necessary. And, of course, you have the option of using your desktop system as your network share, should you always keep it on.

5. (optional) WLAN stick for beefier WLAN connectivity. I used TP-Link Archer T3U.

Note: If you have ethernet connectivity in your TV area, then obviously that is a faster and more reliable way to connect your device to your network. I don't, so I opted to get an external WLAN stick. For that beefier WLAN connection.

Software

Host, installation, and maintenance

1. Linux

I installed Arch Linux on this new media center box, and while installing the operating system is outside the scope of this guide, there is a good guide on the official wiki. The package names listed below are for the Arch Linux repos. Of course, if you prefer to use Debian or whatever, I see no reason why all this wouldn't still work - you'll just have to look up the package names.

2. sshd (core/openssh)

Your bread and butter program for installation and maintenance.

3. (optional) barrier (community/barrier-headless)

Can be handy for testing things out.

4. (optional) git (extra/git)

For pulling your dotfile repo, if you have one.

5. (optional) rsync (extra/rsync)

Good if you don't have a dotfile repo and want to copy over some of your configs.

Our media center

1. flirc_util (aur/flirc-bin)

Whatever old remote you found will be your method of input once everything is setup. Use the flirc_util record <keyboard_key> and then press a button on your remote to assign that remote button to the relevant key. flirc_util delete allows you to unassign buttons, should you mess something up or if you come up with better bindings as you use your system. Note that you have to have your Flirc USB device plugged in when you do this. :)

2. i3 (community/i3-wm)

Any WM will probably do (or maybe even no WM, but I'm no X wizard), and I just went with i3 since that's what I'm used to. You do need some display server, though, be it X or Wayland, otherwise you can't get graphics in your mpv.

Also, flirc_util only allows you to bind single (keyboard) keys to remote buttons and this is where i3's bindsym functionality comes in handy. For instance, perhaps you want to be able to shut off your media PC? The remote probably even comes with an appropriate button for this! With i3 this is pretty simple:

bindsym F12 exec shutdown -h now

And then:

flirc_util record F12 and press the 'power' key on your remote.

Voilà!

3. (optional) nfs (core/nfs-utils) or sshfs (community/sshfs)

If you are storing your video files somewhere on your network, you need some tool to mount the stores on your media center PC.

4. mpv (community/mpv)

We're putting together a media center, so we need a video player. Settings and bindings have sane defaults, but probably you'll want to do some tweaks. We do, however, want to make some remote control assignments for mpv:

flirc_util record space [ play/ pause] *

flirc_util record q [ stop] **

flirc_util record j [subtitle]

* Note: [keys] refer to keys on remote control.

** Note: 'q' is "quit" in multiple programs, so the pieces will fall into place sooner than it may at first seem.

And whatever else you think you need for video playback control.

5. A(ny) terminal (program)

Normally, I use urxvt (community/rxvt-unicode). For this project, I chose cool-retro-term (community/cool-retro-term), just for flavor. Then you just need to assign some button to launch your terminal menu:

flirc_util record F10 [menu]

And then add the corresponding key to your i3 config:

bindsym F10 exec "urxvt -e bash -c 'ranger /tv'"

6. ranger (community/ranger)

And finally, the mighty ranger, to wrap it all together! The ranger file manager, turns out, not only doubles as perfectly acceptable media center UI, but since your entire UI is just files, it's very easy to put together:

mkdir /tv
ln -s /path/to/your/network/share/movies /tv/
ln -s /path/to/your/network/share/shows /tv/

Tip: Perhaps you want your menu ordered a certain way? You can simply replace the second parameter, '/tv/' with something like '"/tv/1. Movies"'. This way it will be ordered first with default directory listing.

And that's basically it! Ok, I lied, we have a bit of a way to go still. We'll add some more stuff there, but that's basically the "core" of our media center. And you can of course add whatever scripts or symlinks you want to this directory. Hopefully, the big picture is revealing itself by this point. Now some more bindings!

flirc_util record up [↑] *

flirc_util record down [↓] *

flirc_util record left [←] *

flirc_util record right [→] *

* Note: Once again, the arrow keys we assign for navigation in ranger also double as the default keys for seeking in mpv.

If you have an existing .Xresources file on your main system, you can probably just copy the configuration, though at minimum you'll probably want to triple your font sizes to make them "TV friendly". ranger also ships with sane defaults, but especially if you use ranger on your main system, you may want to copy your configs, thumbnailers, etc. from that machine.

Perhaps using the power button for off is sufficient, but you could add a bash one-liner in your /tv/ directory called 'Shutdown' with shutdown -h now to improve the UX.

7. (optional) twitch-curses (aur/twitch-curses)

Adding twitch support to our media PC is extremely simple. Existing mpv/ranger keybindings are sufficient to use twitch-curses - all we need to do is add player=mpv to .config/streamlink/config (creating the file if needed - streamlink itself will be pulled as a dependency) and symlinking the (python) binary to our "menu":

ln -s /usr/bin/twitch-curses /tv/Twitch

Done.

8. (optional) spotifyd (community/spotifyd or aur/spotifyd-full-git)

Perhaps your best speakers are connected to your media center? Then maybe you want to use your media center to listen to spotify. At its most simple, we could just symlink the spotifyd binary to our menu directory and then control the playback via a phone. Some configuration is required, though.

9. (optional) whatever you want!

It's a Linux system. You have a file browser to launch programs/scripts. Literally anything is possible. Right there, from your couch, on your TV, with just a remote!