This topic is to explain my setup to transform a Mac Mini mid 2012 to an HTPC. This is running only on Gentoo Linux with Awesome WM , Kodi and Steam.
The setup once installed will have as main input an Apple Remote and a Xbox One controller and as secondary (if needed) a bluetooth Apple keyboard and Magic trackpad.

The Goal

  • UEFI stub kernel
  • OpenRC
  • Kodi booting automatically with auto-login (OpenRC init script)
  • Apple Remote fully functional in Kodi - ATVClient
  • Steam launched by Kodi and controlled with a Xbox One controller
  • Back to Kodi automatically when exit from Steam
  • Zattoo PVR support in Kodi Live TV - pvr.zattoo
  • Gentoo has to be as light as possible



Post edited on 04 of January 2017 - Added section: Fix sound issues with HDMI

Gentoo base installation

Honestly, the best way to install a new fresh Gentoo is to use the Gentoo handbook. The installation of the Gentoo base is not the main focus of this How-to. It's why I will not explain everything but just give a short way to get a functional system. Please keep next to this How-to the gentoo handbook to have more information.

Start the minimal installation

Plug your SystemRescueCD USB-key and boot on it by pressing "ALT" key during the computer boot. You will get a screen with the choice of which system you want to boot, please select the USB EFI boot.
From this time you will get the Grub2 menu from SystemRescueCD, just choose the default selection call SystemRescueCD (64bit, default boot options).
When the SystemRescueCD boot sequence will be finish you will be directly logged with the root account, just run the startx command to get a graphical interface.

From there you should directly have a network connection if your computer is using a wired connection. Then ready to start.
In the Gentoo Handbook please directly jump to the section Preparing the disks.

Preparing the disks

Prepare the disk by following the Gentoo Handbook and use parted or gparted with GPT partition scheme to be able to boot in pure EFI. For my Mac Mini I created 5 partitions like this:

Model: ATA OCZ-VERTEX2 (scsi)
Disk /dev/sda: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start     End        Size       File system     Name    Flags
 1      1.00MiB   3.00MiB    2.00MiB                    grub    bios_grub
 2      3.00MiB   131MiB     128MiB     fat32           boot    boot, esp
 3      131MiB    16515MiB   16384MiB   linux-swap(v1)  swap
 4      16515MiB  47235MiB   30720MiB   ext4            rootfs
 5      47235MiB  228936MiB  181701MiB  ext4            homefs

The partition sda1 will be not use with my setup, I created it just in case of troubles and for a reason I should install Grub2, actually it is not the case and booting with a stub kernel in EFI works well in Apple Computer.
Format the partitions with file systems as in below table.

# mkswap /dev/sda3
# swapon /dev/sda3
# mkfs.vfat /dev/sda2
# mkfs.ext4 /dev/sda4
# mkfs.ext4 /dev/sda5
Mount the partitions and install the stage3

Keep following the Gentoo Handbook to mount the partitions, set the right date if needed, downloading the stage3 tarball and finally unpacking this. Here is the shot of the needed commands:

# mount /dev/sda4 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/sda2 /mnt/gentoo/boot
# cd /mnt/gentoo
# wget
# tar xvjpf stage3-*.tar.bz2 --xattrs
Configuring compile options

It's now the time to create the make.conf file for the compilation options and also create all the files needed by portage to install correctly our Mac Mini with all the correct dependencies. Here is all my configuration files, copy/paste all the next commands:

# cd /mnt/gentoo/etc/portage
# wget
# wget
# wget
# wget

This configuration is done to be as light as possible, feel free to edit it if you want more apps, other desktops and other tools. My idea was to only use wpa_supplicant to manage the wifi connection and AwesomeWM as Window Manager for the switch between Kodi to Steam to Kodi.

Chroot and install base system

Keep reading the Gentoo Handbook and jump to the section Installing the Gentoo base system.
Configure a gentoo mirrors by reading the first optional section of the handbook. When this is done, please chroot in your new Gentoo installation:

# cp -L /etc/resolv.conf /mnt/gentoo/etc/
# cd /mnt/gentoo/etc/portage
# mount -t proc proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# chroot /mnt/gentoo /bin/bash
# source /etc/profile
# export PS1="(chroot) $PS1"

Install the last Portage snapshot:

# emerge-webrsync
# emerge --sync

Now choose a Gentoo profile for your new fresh installation, I used only Gentoo Desktop profile, remember I do not want to install Gnome or KDE:

# eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0
  [2]   default/linux/amd64/13.0/selinux
  [3]   default/linux/amd64/13.0/desktop *
  [4]   default/linux/amd64/13.0/desktop/gnome
# eselect profile set 3

Follow by updating the whole system and take a huge cup of coffee:

# emerge -DuNav @world

During this big time you can read the Gentoo handbook to get more knowledge about what we did and what will be the next steps :)

Next step we will configure the correct timezone:

# ls /usr/share/zoneinfo
# echo "Europe/Zurich" > /etc/timezone
# emerge --config sys-libs/timezone-data

Replace Europe/Zurich by our own timezone.

Now it is time to set your locale:

# nano -w /etc/locale.gen
edit this file with your own locales
# locale-gen
# eselect locale list
Available targets for the LANG variable:
  [1]   C
  [2]   POSIX
  [3]   en_US
  [4]   en_US.iso88591
  [5]   en_US.utf8 *
  [ ]   (free form)
# eselect locale set 5
# env-update && source /etc/profile && export PS1="(chroot) $PS1"
Configuring the kernel

For the kernel configuration I did a specific kernel configuration with not a lot of support inside but enough for what we want, copy the following command to install the kernel and get my configuration file:

# emerge -av gentoo-sources pciutils
# cd /root
# wget
# cp kernel-config-4.4.39 /usr/src/linux/.config
# cd /usr/src/linux
# make silentoldconfig
# make -j 5 && make modules_install && make install
# mkdir -p /boot/efi/boot
# cp /boot/vmlinuz-* /boot/efi/boot/bootx64.efi
# emerge -av sys-kernel/linux-firmware

These last commands install the Gentoo kernel, download my configuration file, copy it to the kernel sources, compile the kernel and its modules and finally install it to the boot partition.

Configuring the system

Now we need to configure the partitions in the file fstab in order to be able to boot to our fresh new installation. Edit this file nano -w /etc/fstab and fill it like below or adapt if you did not create same partitions as me:

/dev/sda2		/boot		vfat		noauto,noatime	1 2
/dev/sda4		/		    ext4		noatime,nodiratime,discard 0 1
/dev/sda3		none		swap		sw 0 0
/dev/sda5		/home		ext4		noatime,nodiratime,discard 0 1

Configure the network by giving an hostname (give the name like you want) specify that we want to used DHCP and activate the wired connection on boot:

# nano -w /etc/conf.d/hostname
# nano -w /etc/conf.d/net

Please adapt your network adapter enp1s0f0 by our own, to check it run this command ifconfig and replace enp1s0f0 by what you have, can be eth0 or en******

Create the init script for your network interface

# cd /etc/init.d
# ln -s net.lo net.enp1s0f0
# rc-update add net.enp1s0f0 default

Set a new root password:

# passwd
write your new password

Configure your keyboard layout:

# nano -w /etc/conf.d/keymaps

Replace fr_Ch by our own keyboard layout.

Install and activate on boot some system tools:

# emerge -av app-admin/sysklogd
# rc-update add sysklogd default
# emerge -av sys-process/cronie
# rc-update add cronie default
# rc-update add sshd default
# emerge -av net-misc/dhcpcd
# emerge -av sys-fs/e2fsprogs
# emerge -av sys-fs/dosfstools
Configuring bootloader

With this configuration we are lucky, we do not need any bootloader as grub or lilo or anything else, you can just jump this section of the handbook.
If needed or if you want you can manage the default UEFI boot with the efibootmgr

It is now time to reboot and cross you fingers to have a fully system booting without any problem...

# exit
# umount -l /mnt/gentoo/dev{/shm,/pts,}
# umount /mnt/gentoo{/boot,/sys,/proc,}
# reboot

If you get a kernel panic, read the error message and try to understand the problem, usually the problem is on the kernel configuration with a bad root partition referenced, if you used the same partitions layout as me and my configuration you should not get any troubles. When you think to have understand the problem you can reboot from the USB key systemrescuecd, chroot in your gentoo, fix the problem, and reboot again.

Install and configure the wifi network card

With this configuration you will see that the wifi card is still not available, let's go ahead to activate and configure it:

# emerge -av net-wireless/broadcom-sta net-wireless/wpa_supplicant
# modprobe wl

To see what is going one and if the drivers is load correctly you can check with the command dmesg

Edit the following net file and fill it like this:

# nano -w /etc/conf.d/net

# Prefer wpa_supplicant over wireless-tools

# It's important to tell wpa_supplicant which driver it should
# be using as it's not very good at guessing yet

Adapt all your network adapter names by checking their name from command ifconfig

Add the init script for the wireless

# cd /etc/init.d
# ln -s net.lo net.wlp2s0
# rc-update add net.wlp2s0 default

Edit the WPA_Supplicant configuration:

# nano -w /etc/wpa_supplicant/wpa_supplicant.conf
# The below line not be changed otherwise wpa_supplicant refuses to work
# Ensure that only root can read the WPA configuration
# Let wpa_supplicant take care of scanning and AP selection
# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
  # The higher the priority the sooner we are matched

Run the init script and check if everything is working:

# /etc/init.d/net.wlp2s0 start

Install some needed stuffs/apps

Actually our Gentoo installation has not a lot of application, I mean, we do not have graphical interface, kodi still missing, etc... Let's install a bunch of applications needed.

# emerge -av x11-base/xorg-x11
# emerge -av awesome
# emerge -av alsa-lib alsa-tools alsa-utils alsamixergui alsa-firmware
# emerge -av git
# emerge -av layman
# emerge -av bluez
# emerge -av x11-apps/xset
# emerge -av kodi
  • Awesome WM is a windows manager which we will use to manage kodi and steam window to have an automatic switch
  • Layman is the tool to manage gentoo overlay, needed to add the steam overlay
  • Bluez is the tool to manage bluetooth
  • Xset will be used to inactivate the X11 default blacksreen after some inactivate minutes
Configure the bluetooth to run at boot

First we need to auto enable the bluetooth controller, edit the file /etc/bluetooth/main.conf and change the line:


Start the service and add it to boot:

# rc-service bluetooth start
# rc-update add bluetooth default

To pair a keyboard or mouse please follow the gentoo how-to

Install atvclient for Apple remote

ATVClient is a small application to give more and less all the native commands of an Apple Remote in Apple TV to Kodi.
Actually there is not any gentoo ebuild for this application and I did not take anytime to create one, we will directly install it from sources without using emerge and we will create a new init script:

# cd root
# git clone
# cd atvclient
# ./configure
# make -j5
# make install
# cd /etc/init.d
# wget
# rc-service atvclient start
# rc-update add atvclient default
Install Steam client
# layman -a steam-overlay
# emerge -av steam-client-meta steam-games-meta steam-launcher steam-meta steamfonts

If you have any problem to use the steam-overlay please follow instructions from gentoo how-to

Add two needed users

For our configuration we will create two users.
The first user will be your regular user, with common permissions and able to run su command for administrative works, like update you system, install new packages, etc...
The second user will be used only to launch kodi and steam automatically and will be not allow to execute root command as su. Replace gulivert by your username, and keep kodi for the second username:

# useradd -m -G wheel,audio,video,usb,users,plugdev,games -s /bin/bash gulivert
# passwd gulivert
# useradd -m -G audio,video,usb,users,plugdev,games -s /bin/bash kodi
# passwd kodi

Configure kodi user environment

First we need to create a new .xinitrc file to run awesome by default when using the command startx:

# login kodi
$ cd
$ wget
$ mv xinitrc ~/.xinitrc

Now if you run command startx you should get Awesome WM with its default configuration. If you get any troubles please check the xorg log /var/log/Xorg.0.log

Awesome WM configuration

To have a correct layout by default in Awesome WM and in the menu two entries, one for kodi and one for steam, we will create a specific configuration file:

$ mkdir -p ~/.config/awesome
$ cd ~/.config/awesome
$ wget
$ wget

Now if you restart your Awesome you should have a better theme for Awesome and if you open the menu you should have two more entries for kodi and steam. We also have autostart configured to run kodi automatically when Awesome start.

In your kodi you also should able to use your Apple Remote :) Nice !!!

You can now close kodi and awesome and go back to your root session, you should still logged with kodi user then you can just do an exit

Autostart Kodi at computer boot

To get kodi running automatically at boot we will create a new init script, in which we will specify that we will start Awesome WM with the user kodi when the boot is finished, we will also specify that we want before to start this init script the network UP:

# cd /etc/init.d
# wget
# rc-update add awesome default

Try it by running the command rc-service awesome start
Awesome should start logged with kodi user and kodi should start automatically inside your Awesome WM.

If everything works, try to reboot your computer. After the boot sequence you should be inside kodi without doing anything.
The bluetooth and network should be also UP and you should be able to use your Apple remote to navigate inside kodi.

Getting zattoo PVR support for Kodi live TV

First we will create a new folder in kodi user homedir which will be used to add a new source entry in kodi. This folder will be used to add some zip file for kodi addon to be able to install them from menu "install from zip file" in kodi.

# login kodi
$ mkdir -p ~/kodi_sources/apps
$ exit

In kodi please add a new source folder in Settings - File Manager - Add source and specify as target this new folder.


Install zattoo.pvr from sources

In root account:

# cd
# git clone -b zattoo
# git clone -b zattoo
# cd pvr.zattoo/ && mkdir build && cd build/
# cmake -DADDONS_TO_BUILD=pvr.zattoo -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/project/cmake/addons
# make -j5
# cd ../../xbmc/addons/
# zip -r pvr.zattoo
# mv /home/kodi/kodi_sources/apps/
# chown kodi:kodi /home/kodi/kodi_sources/apps/


Now the last pvr.zattoo is compiled and ready to be installed, go back to kodi, if it is not running start it with rc-service awesome start

Go to the section Add-ons, click on the icon package on top-left, choose Install from zip file. Choose Kodi apps and install
You now need to configure it and add your zattoo login name and password. Enjoy Zattoo TV inside TV kodi support!!! :)

This plugin run really well, all your channels will be there, you can choose your favorites channel created from the Zattoo web site, the guide is also working and even the recording, only the recall function is not yet supported.


Install Steam addon in kodi

Install steam-launcher addon in kodi by following this how-to


Now you will have a steam icon in your addons library, please go in the configuration and configure it like this:


When you run it, this addon will run steam in big-picture mode.
The Xbox One/360 controller will work without any more effort, just plug it and ENJOY!!!
If you quite Steam you will be back to kodi automatically :)

Fix sound issues with HDMI

With the default configuration the sounds is playing by the MacMini itself instead of the HDMI device as TV or Homecinema, here is a tip to fix it.

First login to kodi user and after get my .asoundrc in your homedir:

# login kodi
$ wget
$ mv asoundrc ~/.asoundrc
$ exit
# rc-service awesome restart

I written this article in one shot by writing information by heart and I did this installation a long time ago. It is also possible that there is some missing information which I am not remember.
If you face to some problems, please just let me know in the comments and I will try to help you an do the needed correction in this how-to.

Thank you for reading and enjoy your new HTPC :-)

© 2018 Gulivert's Blog