Building you own Kodi-flavored Ubuntu Desktop with Cubic

I was experimenting with my HTPC setup and was looking for a “one-click-install” Kodi distribution for x86 PCs. …But there was only one… WTF?! Though Libreelec is looking good, at this point it is just not “there” in terms of availability of packages etc. and it was in beta. I wanted a snapcast server for multi-room audio, Flirc support and some other stuff and hit a road block pretty soon. On the other side of the spectrum there are many instructions to install Kodi standalone on a Debian or Ubuntu server installation. But these are pretty involved and I did not want to mess with the system too much, to stay update- and upgradeable.

I had been running Ubuntu Desktop with Kodi on my HTPC setup in the past and was quite happy with most of it, except its bloatware (snap and preinstalled software) and the fact that I always had to start from scratch. There is the wonderful Cubic (Custom Ubuntu ISO Creator) which lets you chroot into a linux iso and install packages / switch kernels / adjust settings etc. So I kind of worked my way backwards from the regular Ubuntu Focal Fossa 20.04.2 LTS Desktop to what I wanted in a Kodi install. Enter:

Kodibuntu

I called it “Kodibuntu”, because… obvious. It is based on Ubuntu Focal Fossa 20.04.2 LTS Desktop, but has:

  • Snap removed
  • A lot of cruft (office, browsers, games, printer / scanner support etc.) removed
  • Kodi, some audio encoders, some Bluray and Pycryptodome support installed
  • Snapcast server + client installed
  • Lirc and Flirc installed
  • “universe” repo enabled (needed by Kodi)
  • Weekly unattended security updates enabled (Other updates have to be done manually through “apt update && apt upgrade“)
  • Update pop-up / nag screen disabled due to uninstall of packagekit. Note that this removed the Gnome software installer too (but hey, there’s apt install, right?!)
  • File indexing aka tracker-miner disabled
  • “Do not disturb” in gnome enabled by default
  • Gnome lock screen disabled by default (also after suspend)
  • Opt-out from data-collection
  • Ethtool and wake on LAN service pre-installed (edit /etc/systemd/system/wol.service to set your NIC, enable using “sudo systemctl enable wol“)
  • ssh server pre-installed (but disabled)
  • Zstd compression used

En detail

Packages removed (–purge):

  • aisleriot
  • baobab
  • cups*
  • firefox*
  • foomatic-db-compressed-ppds
  • gdb*
  • genisoimage
  • gnome-calculator
  • gnome-calendar
  • gnome-characters
  • gnome-getting-started-docs*
  • gnome-initial-setup
  • gnome-mahjongg
  • gnome-mines
  • gnome-sudoku
  • gnome-system-monitor
  • gnome-todo*
  • gnome-user-docs*
  • gnome-video-effects
  • hunspell*
  • hyphen*
  • libreoffice*
  • mobile-broadband-provider-info
  • mythes*
  • orca
  • openprinting-ppds
  • packagekit
  • popularity-contest
  • printer-driver*
  • remmina*
  • rhythmbox*
  • shotwell*
  • simple-scan
  • sane*
  • snapd
  • thunderbird*
  • totem
  • transmission*
  • usb-creator*
  • ubuntu-docs*
  • wbrazilian wbritish wfrench witalian wngerman wogerman wportuguese wspanish wswiss (not wamerican)
  • xul-ext-ubufox
  • yelp*

Repositories / PPAs added:

Packages installed:

  • kodi
  • kodi-inputstream-adaptive
  • kodi-inputstream-rtmp
  • kodi-audioencoder-flac
  • kodi-audioencoder-lame
  • kodi-audioencoder-vorbis
  • kodi-audioencoder-wav
  • libbluray-bdj
  • lirc
  • build-essential
  • python3-dev
  • python3-pip
  • python3-setuptools
  • python packages: pycryptodomex websocket-client
  • snapserver snapclient
  • curl
  • flirc
  • ethtool
  • openssh-server

Instructions

Remove packages
apt remove --purge aisleriot baobab cups* firefox* foomatic-db-compressed-ppds gdb* genisoimage gnome-calculator gnome-calendar gnome-getting-started-docs* gnome-mahjongg gnome-mines gnome-sudoku gnome-todo* gnome-video-effects gnome-characters gnome-initial-setup gnome-system-monitor gnome-user-docs* hyphen* hunspell* mobile-broadband-provider-info mythes* libreoffice* orca openprinting-ppds popularity-contest printer-driver* remmina* rhythmbox* shotwell* simple-scan sane* thunderbird* transmission* totem* ubuntu-docs* usb-creator* wbrazilian wbritish wfrench witalian wngerman wogerman wportuguese wspanish wswiss xul-ext-ubufox yelp*
Remove snap before install
apt remove --purge snapd

See: https://www.kevin-custer.com/blog/disabling-snaps-in-ubuntu-20-04/

Enable “Do not disturb” and disable “lock on suspend” in gnome by default

Create file /usr/share/glib-2.0/schemas/90_ubuntu-custom.gschema.override containing:

[org.gnome.desktop.notifications]
show-banners = false

[org.gnome.desktop.screensaver]
ubuntu-lock-on-suspend = false
lock-enabled = false

Then run:

glib-compile-schemas /usr/share/glib-2.0/schemas

See: https://askubuntu.com/questions/1233682/remove-gnome-notifications-or-set-permanent-do-not-disturb, https://askubuntu.com/questions/1029696/disable-password-request-from-suspend-18-04 and https://askubuntu.com/questions/1048774/disabling-lock-screen-18-04

Disable tracker / file indexing
systemctl mask tracker-{miner-apps,miner-fs,store}

See: https://www.linuxquestions.org/questions/ubuntu-63/how-to-disable-tracker-globally-in-ubuntu-20-04-a-4175678847/, https://www.linuxuprising.com/2019/07/how-to-completely-disable-tracker.html and https://www.tobiasheide.de/hoher-cpu-verbrauch-durch-tracker-miner-fs-unter-ubuntu-20-04/

Enable weekly unattended security updates

It makes sense to remove the Ubuntu package manager system “packagekit” first if you don’t want to see update popups:

apt remove --purge packagekit

Then enable unattended upgrades:

dpkg-reconfigure --priority=low unattended-upgrades

edit /etc/apt/10periodic:

APT::Periodic::Update-Package-Lists "7";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "14";
APT::Periodic::Unattended-Upgrade "1";

and /etc/apt/20auto-upgrades:

APT::Periodic::Update-Package-Lists "7";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "14";
APT::Periodic::Unattended-Upgrade "1";

See: https://askubuntu.com/questions/1117139/disable-software-updater-notification and https://askubuntu.com/questions/1108738/enable-automatic-updates-from-command-line

Optional: Opt-out from data collection

Create file /etc/xdg/autostart/gnome-initial-setup-report-opt-out.desktop containing:

[Desktop Entry]
Name=GNOME Initial Setup Gnome settings
Type=Application
Exec=ubuntu-report -f send no
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Phase=EarlyInitialization
AutostartCondition=unless-exists gnome-initial-setup-done
X-GNOME-HiddenUnderSystemd=true
X-Ubuntu-Gettext-Domain=gnome-initial-setup

See: https://vitux.com/how-to-force-ubuntu-to-stop-collecting-your-data-from-your-pc/

Optional: Remove post-install dialog
apt remove --purge gnome-initial-setup

See: https://askubuntu.com/questions/1152179/how-can-i-disable-the-connect-your-online-accounts-dialog-from-the-command-li

Remove orphaned packages
apt autoremove --purge && apt autoclean
Add universe and Kodi repositories
add-apt-repository universe
add-apt-repository ppa:team-xbmc/ppa
apt update && apt dist-upgrade
Install Kodi and related
apt install kodi kodi-inputstream-adaptive kodi-inputstream-rtmp kodi-audioencoder-flac kodi-audioencoder-lame kodi-audioencoder-vorbis kodi-audioencoder-wav libbluray-bdj lirc
Optional: Installing pycryptodomex + websocket-client for Netflix etc.
apt install build-essential python3-dev python3-pip python3-setuptools
pip3 install --user pycryptodomex websocket-client
Autostart Kodi

Add a file /etc/xdg/autostart/kodi.desktop is added, containing:

[Desktop Entry]
Type=Application
Exec=/usr/bin/kodi
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
X-GNOME-AutoRestart=true
Name[de_DE]=Kodi
Name=Kodi
Comment[de_DE]=
Comment=

See: https://askubuntu.com/questions/855108/startup-applications-folder-location

Optional: Installing Flirc
apt install curl
curl apt.flirc.tv/install.sh | sudo bash
Optional: Install snapcast
apt install snapsever snapclient
Optional: Snapcast server setup

Edit /etc/pulse/default.pa and add an audio sink for the snapcast server:

### Set up snapcast server sink
load-module module-pipe-sink file=/tmp/snapfifo sink_name=Snapcast format=s16le rate=44100
update-sink-proplist Snapcast device.description="Snapcast" device.icon_name = "network-wired" device.form_factor="speaker"

Edit the snapcast server configuration file /etc/snapserver.conf and change:

sampleformat = 44100:16:2
buffer = 200

Edit the snapcast client options in /etc/default/snapclient to:

SNAPCLIENT_OPTS="--player pulse --host 127.0.0.1"

If you need to adjust the PulseAudio latency for snapcast (was not necessary for me), do that in /etc/environment and add:

# Adjust PulseAudio latency for snapcast server
PULSE_LATENCY_MSEC=60
Optional: Set up Wake-on-LAN

Install ethtool:

apt install ethtool

Add a file /etc/systemd/system/wol.service containing:

[Unit]
Description=Configure Wake-up on LAN

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s enp2s0 wol g

[Install]
WantedBy=basic.target

Make sure you change enp2s0 to the NIC you want to use for WoL. See: https://wiki.ubuntuusers.de/Wake_on_LAN/

Optional: Add SSH access

Install a ssh server:

apt install openssh-server

Enable it:

systemctl enable ssh
Clean up package system
apt autoremove --purge && apt autoclean && apt clean
rm -rf /var/lib/apt/lists/*

Problems

The generated iso is not booting

Try fixing it with isohybrid (from the host, not chroot):
sudo apt install syslinux-utils
sudo isohybrid <YOUR_GENERATED_ISO>

Published by HorstBaerbel

Software developer by trade and interest, but I venture into the electronics- and diy-world from time to time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: