Since a few years I have a Mac mini (Macmini6,1 – late 2012 model).
It was working quite fine, despite its ageing specs.
Equipped with a core i5, 4Gb RAM, an Intel HD Graphics 4000, and a 500 GB 5400 rpm SATA HDD, it was mainly used as an HTPC, wired to my television with HDMI.
Installing software on OSX is quite easy, Plex Media Server is no exception.
Screen sharing across my Macbook and the Mac mini was a breeze.
I had not plugged a mouse or keyboard since the initial configuration.
But, as a developer, it was becoming kind of boring.
OSX updates were slowing this old guy a bit.
And, I admit, I love geeking around, installing and testing new things.
I already installed docker, for the benefit of having containerized torrent/nzb applications (thus easily configured, with a simple configuration file shared and docker-compose).
But, at the time of writing this anyway, docker on OSX still requires a virtual machine.
It can be totally transparent, but it can also impact performance, mostly for mounted volumes.
It was itching too much, and I wanted to give this little guy a new experience.
I will describe here my little journey to having a functional Ubuntu 16.10 on the Mac, with
- Kodi to navigate my media library and play medias
- Plex Media Server to organise this library
- PlexKodiConnect, a plugin to allow Kodi to talk to Plex Media Server
- Apple Remote to, well, be able to navigate Kodi
- Screen sharing between my Macbook and Ubuntu
You might wonder why I installed both Kodi and Plex Media Server.
Simply because all my other devices, such as iPad, iPhone or Android were already connecting to Plex, and it was working flawlessly.
As no plex client is easily available on Ubuntu, I decided to use Kodi because of its beautiful interface, among other things.
The dual boot
I hesitated whether completely format the disk or not.
I heard about rEFInd, so I decided to give it a try.
rEFInd is a UEFI boot manager, fork of rEFIt, allowing to simply boot multiple OSes (see http://www.rodsbooks.com/refind).
It allowed me to keep my OSX on its partition and create another partition for Ubuntu.
The first step is to make some room for, in my case, Ubuntu 16.10 (Yakkety Yak).
We just need to open Disk Utility, and resize the existing OSX partition. Easy!
The next step is to install rEFInd.
I won’t say it’s much more complicated, but you only need to be careful, as recent versions of OSX come with SIP, aka System Integrity Protection, enabled.
Let’s say that SIP protects some system files against modifications, even by root or sudo privileges.
There are some explanations and different ways to install rEFInd here: http://www.rodsbooks.com/refind/sip.html.
I chose what seemed to be the simplest, booting into recovery mode to install rEFInd.
But before, download and unzip it somewhere (in your home directory for instance).
Then, restart the Mac, hold down Command+R when you hear the startup chime, and once you are in Recovery, launch the Terminal.
From the Terminal, cd into the unzipped rEFInd you just downloaded (cd /Volumes/YourVolume/Users/YourUser/…) and launch refind-install (./refind-install).
Ubuntu, the installation
Now we are ready to install Ubuntu!
I downloaded the iso, and followed some guide to create a bootable USB key, similar to this one: https://business.tutsplus.com/tutorials/how-to-create-a-bootable-ubuntu-usb-drive-for-mac-in-os-x–cms-21253.
Now we can plug the USB in the Mac, restart and hold down the option (or alt) key.
The USB should be visible, we launch it and install Ubuntu.
I won’t describe the steps here, because it was pretty straightforward.
Just make sure to install it on the correct partition, or create a new one from the empty space on your disk.
I also created a 1Gb swap partition.
I don’t remember well, but I think after installing Ubuntu, it had replaced rEFInd with grub, or something like that.
I may have reinstalled rEFInd again, to be able to boot OSX or Ubuntu.
Anyway, after that, Ubuntu should run without much trouble.
A lot of things were working out of the box: display, sound, network, ….
At first, as my Mac is connected to my television with HDMI, I thought there was a problem with the resolution as I was not able to see all the Desktop or the top menus.
But I fixed it by modifying the aspect ratio on my television (a Samsung, there is a P.Size button on the remote) and set it to adaptive.
Then I wanted to stop sitting on the carpet right in front of my television screen with the USB keyboard on my lap to fiddle with the settings, so I installed vino.
But it was consuming a lot of CPU, even when not connected remotely.
So I removed it and installed x11vnc, mostly by following the instructions I found here: http://c-nergy.be/blog/?p=8984.
I only encountered a bug when rebooting, fixed by chmod +r /etc/x11vnc.pass (might not be the most secure solution, but sufficient for now).
Under OSX, my Mac was woken up by different triggers.
It was working really well, as soon as I wanted to access it, be it via the Finder to access a shared folder, or via the Screen Sharing app, the Mac would instantly wake up.
I found it more difficult to achieve with Ubuntu.
My first step was to enable the Wake on lan feature, in the network options, I only had to check “Default” for the Wake on lan option in the ethernet tab:
As my Mac came with a remote (more on that just after), I wanted to try to wake up with the remote.
Quite simple actually!
sudo sh -c 'echo "enabled" > /sys/bus/usb/devices/2-1.8.2/power/wakeup'
To persist it, put it in /etc/rc.local:
Mine looks like:
#!/bin/sh echo "enabled" > /sys/bus/usb/devices/2-1.8.2/power/wakeup
To find out the number of the device (2-1.8.2), first get its device ID with lsusb:
dvd@ubuntu-mini:~$ lsusb Bus 002 Device 005: ID 05ac:8242 Apple, Inc. Built-in IR Receiver Bus 002 Device 008: ID 05ac:828a Apple, Inc. Bus 002 Device 004: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) Bus 002 Device 003: ID 0424:2512 Standard Microsystems Corp. USB 2.0 Hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 003: ID 05ac:0221 Apple, Inc. Aluminum Keyboard (ISO) Bus 003 Device 004: ID 1532:0016 Razer USA, Ltd DeathAdder Mouse Bus 003 Device 002: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Here, it is the first line, and the device ID is 8242.
Then we grep our ID in all the idProduct of all the devices, to find the one and only:
dvd@ubuntu-mini:~$ grep 8242 /sys/bus/usb/devices/*/idProduct /sys/bus/usb/devices/2-1.8.2/idProduct:8242
The downside is that any infrared remote will wake the Mac, so as soon as I use my television, my Mac wakes up.
The Multimedia – Kodi, Plex
So, now that I can wake it up, and connect with vnc, it’s time to install the most important software!
I chose Kodi, because I really like the interface and the possibilities.
I liked Plex though, for the server part and the possibility to stream to all of my devices without any issues (Macbook, iPad, iPhone, Android).
So, I decided to install Plex to handle my library, and Kodi as the viewer, thanks to the PlexKodiConnect plugin: https://forums.plex.tv/discussion/210023/plexkodiconnect-let-kodi-talk-to-your-plex.
To install Plex, simply download the installer from their website, and follow the instructions.
I never created a Plex account, and it seems that with the newer versions they push the user to create one.
It can be useful if you want to access your medias from everywhere, but I only want to organize my library and stream locally, so I don’t need one.
They kind of use dark patterns to make it seem like a Plex account is really needed, don’t be intimidated.
The libraries can be configured through the Plex Media Manager app, which actually opens the web interface in your default browser.
To install Kodi, you can follow their guide: http://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux, which can be summarized to:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:team-xbmc/ppa sudo apt-get update sudo apt-get install kodi
Then, to install PlexKodiConnect, or PKC for those in the know, I followed the instructions here: https://github.com/croneter/PlexKodiConnect/wiki/Installation#installation-from-repository-recommended.
Apparently, all the skins are not compatible with this addon, so I installed Titan (which is, and which is also good looking).
I didn’t encounter any particular issues, that is until I wanted to use…
The Mac mini came with a remote, the Apple Remote (mine is the recent aluminum model, A1294).
Let’s say that it’s kind of an important piece for an HTPC.
As I will use the Mac mainly for media watching, I added Kodi to the startup applications.
So when I boot the Mac, it automatically starts Ubuntu, which automatically starts Kodi.
And with the Apple Remote working, everything will be perfect!
I hope to avoid you some trouble and hours of research and tweaking.
In retrospect, it is quite easy.
We will install Lirc (Linux Infrared Remote Control), to decode infra-red signals coming from the remote.
Then, we will create a Lircmap.xml file for Kodi, to define the mappings between Kodi commands and IR commands.
But, most important first, we will tell X11 to ignore inputs coming from the remote.
Indeed, by default, the remote is considered a keyboard.
Even before installing Lirc, some buttons should work, for instance volume up and down will indeed control volume in Ubuntu.
But that will cause trouble with Kodi and Lirc, because IR signals will be treated and (fake IR) keyboard signals also.
In my case, pushing volume down in Kodi moved the selection multiple times down, and also decreased the volume.
Pushing the left (rewind) button on the remote also triggered a lot of inputs, going left multiple times, opening the options menu, …
It was really not useable, and I lost a lot of times trying to fine tune the Lirc configuration file and the Lircmap.xml, to no avail.
The solution was to completely disable the remote in X11, which is really not disturbing since I don’t need to control Ubuntu with my remote, only Kodi.
Find the name of the IR input device:
cat /proc/bus/input/* | grep Name
Mine was: Name=”Apple, Inc. IR Receiver”.
Then add a configuration file in /etc/X11/xorg.conf.d:
sudo vi /etc/X11/xorg.conf.d/00-ir.conf
And the content of the file:
Section "InputClass" Identifier "Remote" MatchProduct "Apple, Inc. IR Receiver" Option "Ignore" "on" EndSection
Restart the display manager (or reboot the machine):
sudo systemctl restart lightdm.service
And now the remote should not do anything.
Time to install Lirc:
sudo apt-get install lirc
I think I selected Mac mini something from the configuration screen.
But that is not really important as we will replace the configuration file.
In my /etc/lirc/lircd.conf, I have the following include:
That comes from what I chose during the installation, if yours is different, edit the file specified here!
Mine looks like:
# # this config file was automatically generated # using lirc-0.8.2(macmini) on Tue Dec 11 11:35:26 2007 # # contributed by Sebastian Schaetzel # # brand: Apple # model no. of remote control: A1156 # devices being controlled by this remote: Mac mini, MacBookPro 15" # SantaRosa (3.1), MacBook2 # begin remote name Apple_A1294 bits 8 eps 30 aeps 100 one 0 0 zero 0 0 pre_data_bits 24 pre_data 0x87EE81 gap 211982 toggle_bit_mask 0x0 ignore_mask 0x0000ff01 begin codes KEY_VOLUMEUP 0x0B KEY_VOLUMEDOWN 0x0D KEY_REWIND 0x08 KEY_FORWARD 0x07 KEY_PLAYPAUSE 0x04 KEY_MENU 0x02 end codes end remote
To test that it is working, restart lirc:
sudo service lirc restart
And launch irw:
irw will connect to any socket and print the data to stdout.
By default, it connects to the lircd socket, so if you press buttons on the remote it should output some data:
dvd@ubuntu-mini:~$ irw 0000000087ee810d 00 KEY_VOLUMEDOWN Apple_A1294 0000000087ee810d 01 KEY_VOLUMEDOWN Apple_A1294 0000000087ee810d 02 KEY_VOLUMEDOWN Apple_A1294 0000000087ee810b 00 KEY_VOLUMEUP Apple_A1294 0000000087ee810b 01 KEY_VOLUMEUP Apple_A1294 0000000087ee8107 00 KEY_FORWARD Apple_A1294 0000000087ee8107 01 KEY_FORWARD Apple_A1294
That confirms that Lirc is correctly configured.
The last step is to map the commands from Lirc to commands that Kodi understands.
To do so, create a file in your home directory:
the capital L is apparently important in the filename, be careful.
The content of my Lircmap.xml is:
<lircmap> <remote device="Apple_A1294"> <up>KEY_VOLUMEUP</up> <down>KEY_VOLUMEDOWN</down> <left>KEY_REWIND</left> <right>KEY_FORWARD</right> <back>KEY_MENU</back> <select>KEY_PLAYPAUSE</select> <volumeplus>noop</volumeplus> <volumeminus>noop</volumeminus> </remote> </lircmap>
The device name should match the Lirc configuration file (Apple_A1294).
The tag names are Kodi commands, and the value should match the codes defined in Lirc configuration file.
I mapped the KEY_MENU to the back command, as it is more useful to go back than to show the menu.
You can still open the menu by going left (in Titan theme at least).
I nooped the volumeplus and volumeminus, meaning my remote will not trigger any volume change.
For now, I never change the volume of Ubuntu or Kodi, only with my TV remote.
I don’t really know if it’s useful or not to noop them, I still have to try different things.
Now you should be able to navigate through Kodi with the remote.
I find the default Unity theme neither beautiful nor ugly.
But I decided to test other themes, and I liked the Numix theme most.
You will need Unity Tweak Tool:
sudo apt-get install unity-tweak-tool
Then add the numix repository and install the numix themes and icons:
sudo add-apt-repository ppa:numix/ppa
They should now be available in Unity Tweak Tool.
Of course, OSX on the Mac mini is a great experience overall.
As the hardware ages out, performances suffer a bit.
This can of course be countered by, for instance, upgrading the HDD to an SSD, or adding more RAM.
Apart from that, I always found OSX very well polished, and with other Apple products in the house, I have to say the ecosystem makes things work seamlessly.
Ubuntu tends to be more snappy.
Overall, things are not as well “integrated” or polished, but with Linux, if you like it, it is not difficult to get the desired configuration.
The rest is a matter of personal taste. If you can live with the fact that some things will not work perfectly, or that you may have to delve into the configuration, then the experience will only be positive.