PART2: Cloning AMD64 UEFI Image Disk From Windows

# we assume you have a PC with Windows system and 7zip (or Winrar) installed
# and GParted Live USB stick bootable


# more info on GParted website to create your a bootable Live system)
# and another USB drive for the image disk

WINDOWS PC

# download the distribution from our website/github and extract it with 7zip (or Winrar)
# insert your USB drive and format it using NTFS with for example ‘imgdisk’ name
# then copy the extracted image disk (.img) from Windows to your USB drive
# optional: rename image disk to musiclounge.img or medialounge.img

BAREBONE PC (HTPC)

# insert the the GParted Live USB, the imgdisk usb stick, plug a keyboard (and optionally a mouse)
# and turn the HTPC ON
# quickly hit F10 (NUC) or F12 to show up the boot menu
# boot UEFI:disk corresponding to GParted live USB
# GParted app should be opened so you can identify easily
# your internal hard drive (/dev/sda) and your USB stick ‘imgdisk’ (/dev/sdX)
# in our example:

internal hard drive (ssd): /dev/sda
imgdisk partition 1: /dev/sdb1

# QUIT GParted app

# open terminal with root permissions
# mount your usb imgdisk

  1. $ mount /dev/sdX /media
  2. $ cd /media
  3. $ ls

# IMPORTANT: check the integrity of the image disk

  1. $ sha1sum medialounge....img

# compare the result with the SHA1 line on website
# if this doesn’t match then your image disk is corrupted, you can’t go further until your img disk is clean
# clone from image disk to your internal disk (/dev/sda)
# ALL DATA IN INTERNAL HARD DRIVE/SSD WILL BE ERASED

  1. $ sudo dd if=musiclounge.img of=/dev/sda bs=2048 status=progress

# then fix gpt backup header/table on the target disk

  1. $ sudo sgdisk -e /dev/sda

# unmount /media

  1. $ cd /
  2. $ umount /media

# now launch GParted app to resize the root partition (3) of your internal disk (/dev/sda3)

# double-check and APPLY all changes

# expand partition 3 (minimum 16GB)


# shutdown your HTPC
# remove both GParted live usb and imgdisk usb drive

# congrats! You are now ready to enjoy your distribution

PART1: Cloning AMD64 UEFI Image Disk From Windows (Rufus)

# we assume you have a PC with Windows system with 7zip (or Winrar) and Rufus installed
# an USB Drive with GParted Live USB bootable


# more info on GParted website to create your a bootable Live system)


# and an USB3 To SATA adapter cable

# if you do not have the cable, follow the instructions of SOLUTION 2

WINDOWS PC

# download the distribution from our website/github and extract it with 7zip or Winrar

# IMPORTANT: check the integrity of the image disk
# and compare the result with the corresponding SHA256 line on website

# run powershell (i.e. Windows Terminal) and type:

Get-FileHash C:\path\to\imagedisk.img

# if this doesn’t match then your image disk is corrupted, you can’t go further until your img disk is clean
# connect your SSD (or 2.5″ Hard drive) to your PC with the Startech USB3 To SATA adapter


# then run Rufus and select the image disk, tick the “List USB Hard Drives” and select your SSD
# clone from image disk to your internal disk
#ALL DATA IN INTERNAL HARD DRIVE/SSD WILL BE ERASED


# After the cloning, close Rufus, disconnect the adapter cable from the PC and mount the SSD inside your Barebone PC/NUC

BAREBONE PC (HTPC)

# insert the the GParted Live USB, plug a keyboard (and optionally a mouse)
# and turn the HTPC ON
# quickly hit F10 (NUC) or F12 to show up the boot menu
# boot UEFI:disk corresponding to GParted live USB
# GParted app should be opened so you can identify easily
# your internal hard drive (/dev/sda)
# Fix the GPT backup header/table if GParted prompts to do so

# resize the root partition of your internal disk (/dev/sda3)

# double-check and APPLY all changes

# expand partition 3 (minimum 16GB)


# shutdown your HTPC
# remove both GParted live usb

# congrats! You are now ready to enjoy your distribution

MediaLounge Audiophile Home Theater Server


# Audiophile Music Player And Kodi Home Theater Software#
# the best combo to take benefit to your audio and video system
# Ubuntu Kinetic Kudu Live 22.10 Based (Kernel 5.19)

# follow instructions below to build your own Audiophile Home Theater Server
# MediaLounge server includes almost all audiophile services of MusicLounge with the addition of Kodi Home Theater software, HEVC – 4K60fps – HDR10 supported (tested on Intel NUC)

# To get the best audio quality
# Connect the USB dac to the stereo HIFI pre-amp using a dedicated stereo hifi speakers
# and the HDMI cable to a 3.1 or 5.1 or 7.1 AV Receiver with dedicated home theater speakers


# Full Session Transcription

# install Ubuntu Live Server amd64

# select minimal server installation (set Minimized option)
# username pi
# hostname medialounge

# pick username pi
# password musiclounge

# Install openSSH [yes]

# in case of server install stuck on “curtin command in-target” with “Install Complete!” on top bar
# check by selecting [View Full Log] and if the install is freezed then
# choose “cancel update & reboot”
# (force reboot if needed)

# server is now installed


# open ssh sesssion
# follow the instructions below

 


login pi

# install nano

  1. $ sudo apt install nano

# disable cd-rom release, comment cdrom line in sources list if exists

  1. $ sudo nano /etc/apt/sources.list

#deb [check-date=no] file:///cdrom jammy main restricted

# CTRL X +Y to SAVE

#update distro

  1. $ sudo apt update

#upgrade

  1. $ sudo apt upgrade

# check for update again until All packages are up to date.

# in case of “The following packages have been kept back:”
# force install of left back pkgs

  1. $ sudo apt-get install (list of packages)

# install auto completion

 

  1. $ sudo apt-get install bash-completion

# logout
# reopen ssh sesssion


# add sudoers after installation

 

  1. $ sudo nano /etc/sudoers

# add the line below after root ALL=(ALL:ALL) ALL

user ALL=(ALL:ALL) ALL

# CTRL X +Y to SAVE

  1. $ mkdir Downloads
  1. $ mkdir scripts
  1. $ ls

# hostname

# check hostname should be musiclounge or medialounge
hostnamectl

 

  1. $ sudo nano /etc/hostname

# check host

  1. $ sudo nano /etc/hosts

# disable cloud-init

 

  1. $ sudo touch /etc/cloud/cloud-init.disabled

# Disable all cloud services
# uncheck all except “No-Cloud” on first line

  1. $ sudo dpkg-reconfigure cloud-init

# install samba

# read the dedicated tutorial for more info

  1. $ sudo apt-get install samba samba-common smbclient samba-common-bin smbclient cifs-utils
  1. $ sudo mkdir /mnt/media

ls /mnt/media/

# add your fstab entry

# add your fstab entry to mount your music library to /mnt/media

  1. $ sudo nano /etc/fstab

//192.168.x.x/music /mnt/media cifs username=guest,password=,vers=2.0,uid=1000,gid=1000,dir_mode=0755,file_mode=0755,x-systemd.before=mpd.service,x-systemd.device-timeout=10 0 0

# CTRL X +Y to SAVE

# check mount point

  1. $ sudo systemctl daemon-reload
  1. $ sudo mount -a
  1. $ ls /mnt/media/

# you should see your files otherwise fix fstab (see the instructions above)


# install nginx

# read the dedicated tutorial for more info

  1. $ sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm php-intl imagemagick

# add gzip settings from gzip on

  1. $ sudo nano /etc/nginx/nginx.conf
 gzip on;
 gzip_vary on;
 gzip_buffers 16 8k;
 gzip_comp_level 6;
 gzip_min_length 1000;
 gzip_proxied expired no-cache no-store private auth;
 gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
 gzip_disable msie6;
 gzip_http_version 1.1;

# CTRL X +Y to SAVE

# edit defaut settings,

  1. $ sudo nano /etc/nginx/sites-available/default

# replace

location / {
	# First attempt to serve request as file, then
	# as directory, then fall back to displaying a 404.
	try_files $uri $uri/ =404;
}

# with:

location /favicon.ico {
        alias /var/www/html/ml_play.png;
}
location /music {
	alias /mnt/media;
}
location /mympd/ {
	proxy_pass http://127.0.0.1:8080/;
}
location / {
	return 301 http://$host:8080/;
	# First attempt to serve request as file, then
	# as directory, then fall back to displaying a 404.
	try_files $uri $uri/ =404;
}

# CTRL X +Y to SAVE

  1. $ sudo mkdir /var/www/html/tmp
  1. $ sudo usermod -a -G www-data pi
  1. $ sudo chown -R www-data:www-data /var/www
  1. $ sudo chmod -R g+rwX /var/www
  1. $ sudo ln -s /var/www/ ~/www
  1. $ sudo systemctl restart nginx

# add pi to audio and other groups

 

  1. $ sudo usermod -aG adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,render,netdev pi

# for Raspberry PI add gpio i2c spi

  1. $  sudo usermod -aG  adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,render,netdev,gpio,i2c,spi pi

# check ALSA

  1. $ aplay -l

# in case of error or no sound card try

  1. $ sudo aplay -l

# if OK with list of sound cards including your DAC

aplay -l

# if sound card not found install alsa


# INSTALL ALSA if DAC not found

  1. $ sudo apt-get install alsa-utils alsa-tools libasound2
  1. $ sudo systemctl enable alsa-utils.service

# if alsa service is masked unmask it

  1. $ sudo rm /lib/systemd/system/alsa-utils.service
  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable alsa-utils
  1. $ sudo systemctl start alsa-utils

# check alsa status

  1. $ sudo systemctl status alsa-utils.service
  1. $ sudo reboot

# reopen SSH session

  1. $ aplay -l

# your USB DAC should be in card *1*

# in case your DAC takes (sometime) index zero(0)

  1. $ sudo cat /proc/asound/modules
 0 snd_usb_audio
 1 snd_hda_intel

cat /proc/asound/cards

 0 [MQA ]: USB-Audio - D90 MQA
           Topping D90 MQA at usb-0000:00:14.0-3, high speed
 1 [PCH ]: HDA-Intel - HDA Intel PCH
           HDA Intel PCH at 0xd0710000 irq 96

# just reboot or
# change the usb sound card priority

  1. $ sudo nano /etc/modprobe.d/alsa-base.conf

# add this line to change order of devices

options snd_usb_audio index=-2

# CTRL X +Y to SAVE


# in case of error purge and reinstall ALSA

# alsa-base pkg could be omited if not present in repository

  1. $ sudo dpkg -l alsa*
  1. $ sudo apt --purge remove alsa-base alsa-firmware-loaders alsa-oss alsa-source alsa-tools alsa-tools-gui alsa-topology-conf alsa-ucm-conf alsamixergui alsa-utils

# then GO TO INSTALL ALSA instructions above


# create a simbolic link for backward compatibility with old packages

# which target by default the configuration file in /usr/local/etc/

 

  1. $ ls /usr/local/etc

# result should be empty or not found then type

  1. $ sudo rm -r /usr/local/etc
  1. $ sudo ln -s /etc /usr/local/

# type again

  1. $ ls /usr/local/etc

# now etc/ directory is correctly linked


# install MPD server

  1. $ sudo apt install mpd mpc
  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable mpd
  1. $ sudo systemctl start mpd
  1. $ sudo systemctl status mpd

# check version
mpd -V

# should be => 0.23.12


# optional: compile and install latest MPD

 

# website: https://www.musicpd.org/

# check compiler version
gcc –version

# install gcc if not found (GCC 10 or greater)

  1. $ sudo apt -y install build-essential
  1. $ cd ~/Downloads

# install git if not found

  1. $ sudo apt install git

# clone MPD git (or download latest stable and extract)

  1. $ sudo git clone https://github.com/MusicPlayerDaemon/MPD.git
  1. $ cd MPD/

# install ninja

  1. $ sudo apt-get install ninja-build

# dependencies
#(libboost-dev is only needed for old MPD version)

  1. $ sudo apt install meson g++ \
libfmt-dev \
libpcre2-dev \
libmad0-dev libmpg123-dev libid3tag0-dev \
libflac-dev libvorbis-dev libopus-dev libogg-dev \
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
libfluidsynth-dev libgme-dev libmikmod-dev libmodplug-dev \
libmpcdec-dev libwavpack-dev libwildmidi-dev \
libsidplay2-dev libsidutils-dev libresid-builder-dev \
libavcodec-dev libavformat-dev \
libmp3lame-dev libtwolame-dev libshine-dev \
libsamplerate0-dev libsoxr-dev \
libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
libzzip-dev \
libcurl4-gnutls-dev libyajl-dev libexpat-dev \
libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
libpulse-dev libshout3-dev \
libsndio-dev \
libmpdclient-dev \
libnfs-dev \
libupnp-dev \
libavahi-client-dev \
libsqlite3-dev \
libsystemd-dev \
libgtest-dev \
libboost-dev \
libicu-dev \
libchromaprint-dev \
libgcrypt20-dev 

# meson version => 0.56
meson -v

# configure

  1. $ sudo meson . output/release --buildtype=debugoptimized -Db_ndebug=true -Dsysconfdir=/etc

# check config

  1. $ sudo meson configure output/release

# compile (take a while be patient…)

  1. $ sudo ninja -C output/release

# install

  1. $ sudo ninja -C output/release install

# return home

  1. $ cd ~/

# configure and start MPD daemon

 

  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable mpd

# edit /etc/mpd.conf (copy / paste conf read tutorial)
# mpd is configured with sound card 1 (“hw:1,0”)

 

# backup

  1. $ sudo cp /etc/mpd.conf Downloads/mpd.conf.bak

# clear

  1. $ sudo truncate -s 0 /etc/mpd.conf

# edit

  1. $ sudo nano /etc/mpd.conf

# copy and paste these lines

music_directory "/mnt/media"
playlist_directory "/var/lib/mpd/playlists"
db_file "/var/lib/mpd/tag_cache"
log_file "/var/log/mpd/mpd.log"
# uncomment pid_file if you do not use systemd 
#pid_file "/run/mpd/pid"
state_file "/var/lib/mpd/state"
sticker_file "/var/lib/mpd/sticker.sql"
user "mpd"
group "audio"
bind_to_address "any"
port "6600"
log_level "default"
restore_paused "yes"
#save_absolute_paths_in_playlists "no"
#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
#metadata_to_use "+comment"
auto_update "no"
#auto_update_depth "3"
follow_outside_symlinks "yes"
follow_inside_symlinks "yes"
zeroconf_enabled "no"
zeroconf_name "Music DAC"
connection_timeout "120"
#password "password@read,add,control,admin"
#default_permissions "read,add,control,admin"
#
###############################################################################

# Database #######################################################################
#

#database {
# plugin "proxy"
# host "other.mpd.host"
# port "6600"
#}

# Input #######################################################################
#

input {
plugin "curl"
# proxy "proxy.isp.com:8080"
# proxy_user "user"
# proxy_password "password"
}

# QOBUZ input plugin
input {
enabled "no"
plugin "qobuz"
# app_id "ID"
# app_secret "SECRET"
# username "USERNAME"
# password "PASSWORD"
# format_id "N"
}

# TIDAL input plugin
input {
enabled "no"
plugin "tidal"
# token "TOKEN"
# username "USERNAME"
# password "PASSWORD"
# audioquality "Q"
}

# Decoder #####################################################################
#

decoder {
plugin "ffmpeg"
enabled "yes"
# gapless "no"
}

decoder {
plugin "wildmidi"
enabled "no"
}

replaygain "off"
replaygain_preamp "0"
#replaygain_missing_preamp "0"
#replaygain_limit "yes"
volume_normalization "no"
filesystem_charset "UTF-8"

###############################################################################

audio_output {
type "alsa"
name "Default"
device "hw:1,0"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA DAC DOP"
device "hw:1,0"
mixer_type "none"
dop "yes"
}

audio_output {
type "alsa"
name "ALSA DAC NoDOP"
device "hw:1,0"
mixer_type "none"
dop "no"
}

audio_buffer_size "4096"
#buffer_before_play "10%"
max_output_buffer_size "131072"
max_connections "128"

audio_output {
type "alsa"
name "ALSA EQ"
device "plug:plugequal"
# format "44100:16:2" # optional
# mixer_device "default" # optional
# mixer_control "PCM" # optional
# mixer_index "0" # optional
}

# optional output to stream music to local device (phone, tablet, pc,...)
audio_output {
type            "httpd"
name            "Local Stream"
encoder         "vorbis"
#encoder        "lame"         # comment vorbis and use lame for iOS support
port            "8000"
quality         "5.0"           # do not define if bitrate is defined
#bitrate        "128"           # do not define if quality is defined
#format          "44100:16:1"
always_on       "yes"           # prevent MPD from disconnecting all listeners when playback
tags            "yes"           # httpd supports sending tags to listening streams.
}

# CTRL + X the Y to SAVE

# start MPD service

  1. $ sudo systemctl restart mpd

# configure smb share points

# (copy/past at the end, read the tutorial)

 

  1. $ sudo nano /etc/samba/smb.conf
[playlists]
path = /var/lib/mpd/playlists
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = mpd

[music]
path = /mnt/media
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = mpd

[www]
path = /var/www/html
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = www-data

[Downloads]
path = /home/pi/Downloads
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[scripts]
path = /home/pi/scripts
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[sdcard]
path = /home/pi
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = root

# CTRL + X the Y to SAVE

  1. $ sudo /etc/init.d/smbd restart

# now you have acces to www folder from the network
# download and copy at least the faveicon ( ml_play.png by default)
# and your hmtl files if used
[ml_play.png] image


# Install latest myMPD

  1. $ cd ~/Downloads

# install git if not found

  1. $ sudo apt install git

# clone myMPD git

  1. $ sudo git clone https://github.com/jcorporation/myMPD.git
  1. $ cd myMPD
  1. $ sudo ./build.sh installdeps
  1. $ sudo ./build.sh release
  1. $ sudo ./build.sh install

# myMPD is now installed
# create config files

  1. $ sudo systemd-run -t -p DynamicUser=yes -p StateDirectory=mympd -p CacheDirectory=mympd /usr/bin/mympd -c

# update port 8080

  1. $ sudo nano /var/lib/mympd/config/http_port

# CTRL + X the Y to SAVE

# disable (false) ssl

  1. $ sudo nano /var/lib/mympd/config/ssl

# CTRL + X the Y to SAVE

# optional set log level to ERROR (3) (avoid thousands WARN AlbumArtistSort missing in log)

  1. $ sudo nano /var/lib/mympd/config/loglevel

# CTRL + X the Y to SAVE

# start myMPD

  1. $ sudo systemctl enable mympd
  1. $ sudo systemctl start mympd
  1. $ sudo systemctl status mympd

# return home

  1. $ cd ~/

# ALSA EQ

  1. $ sudo apt-get install libasound2-plugin-equal
  1. $ sudo nano /var/lib/mpd/.asoundrc
pcm.!default {
type plug
slave.pcm plugequal;
}
ctl.!default {
type hw card 0
}
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
slave.pcm "plughw:1,0"; # NOTE this line MUST be your hardware device.
}
pcm.equal {
type plug;
slave.pcm plugequal;
}

# CTRL + X the Y to SAVE

# check ALSA EQ

  1. $ sudo -H -u mpd alsamixer -D equal

# trigger scripts with a remote control to configure the EQ
# examples
# scripts select automatically the ALSA EQ audio output (see the MPD conf for more info)

  1. $ sudo nano ~/scripts/lowbass.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# CTRL + X the Y to SAVE

  1. $ sudo chmod +x ~/scripts/lowbass.sh
  1. $ sudo nano ~/scripts/jbleq.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 62
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 70
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 71
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# CTRL + X the Y to SAVE

  1. $ sudo chmod +x ~/scripts/jbleq.sh

# assign pi user:group to all scripts

  1. $ sudo chown $USER:$USER  ~/scripts/*

# Optional: Triggerhappy (remote control management)

 

  1. $ sudo apt-get install triggerhappy -y
  1. $ sudo nano /etc/triggerhappy/triggers.d/triggers.conf
KEY_PLAY 0 mpc play >/dev/null
KEY_STOP 0 mpc stop >/dev/null
KEY_PAUSE 0 mpc toggle >/dev/null
KEY_PLAYPAUSE 0 mpc toggle >/dev/null 
KEY_NEXT 0 mpc next >/dev/null
KEY_PREVIOUS 0 mpc prev >/dev/null
KEY_FASTFORWARD 0 mpc seek +10 >/dev/null
KEY_REWIND 0 mpc seek -10 >/dev/null
KEY_RECORD 0 /home/pi/scripts/./playlist.sh >/dev/null
KEY_LEFTCTRL+KEY_P 0 mpc play >/dev/null
KEY_LEFTCTRL+KEY_S 0 mpc stop >/dev/null
BTN_MIDDLE 0 mpc toggle >/dev/null
BTN_LEFT 0 mpc prev >/dev/null
KEY_LEFTCTRL+KEY_B 0 mpc prev >/dev/null
KEY_LEFTCTRL+KEY_F 0 mpc next >/dev/null
KEY_HOME 0 mpc toggle >/dev/null
KEY_LEFTSHIFT+KEY_B 0 mpc seek -10 >/dev/null
KEY_LEFTSHIFT+KEY_F 0 mpc seek +10 >/dev/null
KEY_NUMERIC_1 0 /home/pi/scripts/./playlist1.sh >/dev/null 
KEY_NUMERIC_2 0 /home/pi/scripts/./playlist2.sh >/dev/null
KEY_NUMERIC_3 0 /home/pi/scripts/./playlist3.sh >/dev/null
KEY_NUMERIC_6 0 /home/pi/scripts/./lowbass.sh >/dev/null
KEY_NUMERIC_9 0 /home/pi/scripts/./jbleq.sh >/dev/null
KEY_NUMERIC_0 0 mpc enable only 1 && mpc play >/dev/null
KEY_0 0 mpc enable only 1 && mpc play >/dev/null
KEY_1 0 /home/pi/scripts/./playlist1.sh >/dev/null 
KEY_2 0 /home/pi/scripts/./playlist2.sh >/dev/null 
KEY_3 0 /home/pi/scripts/./playlist3.sh >/dev/null 
KEY_6 0 /home/pi/scripts/./lowbass.sh >/dev/null
KEY_9 0 /home/pi/scripts/./jbleq.sh >/dev/null

# CTRL + X the Y to SAVE

  1. $ sudo nano /lib/systemd/system/triggerhappy.service

# change in ExecStart line

-–user nobody

# by

-–user root

# CTRL + X the Y to SAVE

  1. $ sudo nano /etc/default/triggerhappy

# comment

#DAEMON_OPTS=""

# uncomment

DAEMON_OPTS="--user root"

# CTRL + X the Y to SAVE

  1. $ sudo systemctl enable triggerhappy
  1. $ sudo systemctl start triggerhappy
  1. $ sudo systemctl status triggerhappy

# optional: playlist scripts

 

  1. $ sudo nano ~/scripts/playlist1.sh
#!/bin/bash
#
# Script to load playlist

echo "start playlist"
mpc stop
mpc clear
mpc enable only 1
mpc load my_classical_albums
mpc random "on"
mpc crossfade 0
mpc play

# CTRL + X the Y to SAVE

  1. $ sudo chmod +x ~/scripts/playlist1.sh
  1. $ sudo nano ~/scripts/playlist2.sh
#!/bin/bash
#
# Script to load playlist
 
echo "start playlist"
mpc stop
mpc clear
mpc enable only 1
mpc load my_jazzy_albums
mpc random "on"
mpc crossfade 0
mpc play

# CTRL + X the Y to SAVE

  1. $ sudo chmod +x ~/scripts/playlist2.sh

# install DLNA

 

  1. $ sudo apt install minidlna -y

# edit conf and chage media_dir and friendly_name

  1. $ sudo nano /etc/minidlna.conf
media_dir=A,/mnt/media
friendly_name=MediaLounge

# CTRL + X the Y to SAVE

  1. $ sudo usermod -a -G minidlna pi
  1. $ sudo systemctl enable minidlna
  1. $ sudo systemctl start minidlna
  1. $ sudo systemctl status  minidlna
  1. $ sudo cat /var/log/minidlna/minidlna.log

# in case of error related to max_userwatches

  1. $ sudo nano /etc/sysctl.conf

# add these lines

fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=524288

# CTRL + X the Y to SAVE


# install UPNP renderer

 

  1. $ sudo add-apt-repository ppa:jean-francois-dockes/upnpp1
  1. $ sudo apt install upmpdcli -y

# edit conf and chage friendlyname, upnpav and checkcontentformat

  1. $ sudo nano /etc/upmpdcli.conf
friendlyname = MediaLounge
upnpav = 0
checkcontentformat = 0

# CTRL + X the Y to SAVE

  1. $ sudo systemctl enable upmpdcli
  1. $ sudo systemctl start upmpdcli
  1. $ sudo systemctl status upmpdcli

# install Spotify Connect

 

  1. $ sudo apt-get -y install curl && curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
  2.  
  3. # edit conf and chage LIBRESPOT_NAME, LIBRESPOT_BITRATE and LIBRESPOT_DEVICE (with sound card 1)
  1. $ sudo nano /etc/raspotify/conf
LIBRESPOT_NAME="MediaLounge"
LIBRESPOT_BITRATE="160"
LIBRESPOT_DEVICE="plughw:1,0"

# CTRL + X the Y to SAVE

  1. $ sudo systemctl enable raspotify
  1. $ sudo systemctl start raspotify
  1. $ sudo systemctl status raspotify

  1. # AIR PLAY

 

  1. $ sudo apt-get install autoconf automake avahi-daemon build-essential git libasound2-dev libavahi-client-dev libconfig-dev libdaemon-dev libpopt-dev libssl-dev libtool xmltoman
  1. $ cd ~/Downloads/
  1. $ sudo git clone https://github.com/mikebrady/shairport-sync.git

cd shairport-sync

autoreconf -i -f
./configure –with-alsa –with-avahi –with-ssl=openssl –with-systemd –with-metadata

  1. $ sudo make install

# edit conf and chage LIBRESPOT_NAME, LIBRESPOT_BITRATE and LIBRESPOT_DEVICE (with sound card 1)

  1. $ sudo nano /etc/shairport-sync.conf
name="MediaLounge"

output_device="plughw:1,0"

# CTRL + X the Y to SAVE

  1. $ sudo systemctl enable shairport-sync
  1. $ sudo systemctl start shairport-sync
  1. $ sudo systemctl status shairport-sync

# disable pipewire services if exists

  1. systemctl --global stop pipewire
  2. systemctl --global stop pipewire.socket
  3. systemctl --global stop pipewire-media-session
  4. systemctl --global disable pipewire
  1. $ sudo systemctl --global disable pipewire
  1. $ sudo systemctl --global disable pipewire-media-session

# optional reboot

  1. $ sudo reboot

# update music library database

# be patient could take a while if your music library is big…
mpc update

# reopen SSH session

# check the Roon tutorial HERE to install Roon Server if needed

# cleanup pkgs

  1. $ sudo apt clean
  1. $ sudo apt autoremove

# Congrats! the first “Audiophile” part of this distro is ready

# time to enjoy your music and test if the
# audiophile server part is correctly installed.

# browse and play your music from a browser using myMPD
http://medialounge:8080
# or with a MPD client like MALP or DroidMyMPD
# check the remote control
# use a DLNA client VLC or BubbleUPnP to browse and play your music
# check the upnp renderer
# check Spotify by playing your favorite
# song and using MediaLounge Spotify Connect
# check the AirPlay with apple device or TuneBlade on Windows
# and open your Roon client to browse and play you music



# KODI Installation (Ubuntu)



  1. $ sudo apt install software-properties-common
  1. $ sudo add-apt-repository -y ppa:team-xbmc/ppa
  1. $ sudo apt install kodi

# enable power policy for pi user

 

  1. $ sudo nano /etc/polkit-1/localauthority/50-local.d/50-kodi.pkla
[Allow consolekit]
Identity=unix-group:plugdev
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.f?reedesktop.udisks.*
#Action=org.freedesktop.consolekit*
ResultAny=yes
ResultInactive=no
ResultActive=yes

[Allow login1]
Identity=unix-group:plugdev
Action=org.freedesktop.login1*
ResultAny=yes
ResultInactive=no
ResultActive=yes

[Allow Upower]
Identity=unix-group:plugdev
Action=org.freedesktop.upower*
ResultAny=yes
ResultInactive=no
ResultActive=yes

# CTRL + X the Y to SAVE


# create kodi service

 

  1. $ sudo nano /lib/systemd/system/kodi.service
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target
Wants = network-online.target

[Service]
User = pi
Group = pi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = on-abort
RestartSec = 5

[Install]
WantedBy = multi-user.target

# CTRL + X the Y to SAVE

  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable kodi
  1. $ sudo systemctl start kodi
  1. $ sudo systemctl status kodi

# add kodi smb share points at the end of conf

 

  1. $ sudo nano /etc/samba/smb.conf
[kodi]
path = /home/pi/.kodi
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[userdata]
path = /home/pi/.kodi/userdata
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

# CTRL + X the Y to SAVE

  1. $ sudo systemctl restart smbd
  1. $ sudo reboot

# Adding media source to Kodi

 

# IMPORTANT NOTICE for Windows network SMB share in Kodi 20
# make sure to configure your NAS with shared folders using SMB v2 or v3 and with
# access to everyone (no user/pass)

# setup KODI SMB service with minimum version SMBv2 and maximum SMBv3
# browse the network from a PC and check if you have a full access to shared
# folders without needing to enter your credential
# then in Kodi create your movies, TV shows, etc. source points (i.e. //MYSERVER/Video ) with
# a dummy username and password (like username: srcmedia and paswd: srckodi)


# OPTIONAL: create Video and TV Shows folders if you store the media on the server (not recommended)

  1. $ cd ~/
  1. $ mkdir Video
  1. $ mkdir "TV Shows"

# setup HDMI CEC

# do not forget to add the Pulse Heigh CEC adapter ( https://www.pulse-eight.com ) to be able to use the TV remote control even with the Intel NUC which have a poor CEC implementation (you may need to deactivated internal IR Receiver and HDMI CEC in Intel NUC Bios).

# Congrats! The audiophile server and the Kodi Home Theater are ready

# setup the Kodi SYSTEM > AUDIO > and choose the correct number of speakers
# activate the passthrough to take benefit of Dolby, DTS, trueHD, etc.


# install rc6 mce IR remote control with Kodi 20

# by default Kodi manages the RC6 MCE remote control if your usb dongle is installed or the built in extended IR receiver is set in your bios
# unfortunately some essential buttons of the remote control do not work like BACK (KEY_BACK) and OK (KEY_OK) for example. Read the instructions below to fix it.
# open SSH session
# install ir-keytable

  1. $ sudo apt install ir-keytable

# check if remote control is recognized

  1. $ sudo ir-keytable

# result for usb dongle (mceusb)

Found /sys/class/rc/rc0/ with:
        Name: Media Center Ed. eHome Infrared Remote Transceiver (147a:e03e)
        Driver: mceusb
        Default keymap: rc-rc6-mce
        Input device: /dev/input/event6
        LIRC device: /dev/lirc0
        Attached BPF protocols: Operation not supported
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
        Enabled kernel protocols: lirc rc-6
        bus: 3, vendor/product: 147a:e03e, version: 0x1201
        Repeat delay = 500 ms, repeat period = 125 ms

# example with build IR (cir)

Found /sys/class/rc/rc0/ with:
        Name: ITE8708 CIR transceiver
        Driver: ite-cir
        Default keymap: rc-rc6-mce
        Input device: /dev/input/event4
        LIRC device: /dev/lirc0
        Attached BPF protocols: Operation not supported
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
        Enabled kernel protocols: lirc rc-6
        bus: 25, vendor/product: 1283:0000, version: 0x0000
        Repeat delay = 500 ms, repeat period = 125 ms

# Important Info are:

 system device: rc0 (Found /sys/class/rc/rc0/)
driver: mceusb or ite-cir
protocol: rc-6

# copy the rc6 mce keymap rc6_mce.toml from /lib/udev/rc_keymaps/ to /etc/rc_keymaps/

  1. $ sudo cp /lib/udev/rc_keymaps/rc6_mce.toml /etc/rc_keymaps/

# edit the keymap to fix it

  1. $ sudo nano /etc/rc_keymaps/rc6_mce.toml

# replace entries 0x800f0412, 0x800f0413, 0x800f0418, 0x800f0422 and 0x800f0423 with:

.
.
0x800f0412 = "KEY_PAGEUP"
0x800f0413 = "KEY_PAGEDOWN"
.
0x800f0418 = "KEY_PLAY"
.
.
0x800f0422 = "KEY_ENTER"
0x800f0423 = "KEY_BACK"

# CTRL+X then Y to save

# edit /etc/rc_maps.cfg to add our custom keymap for mceusb and ite-cir driver

  1. $ sudo nano /etc/rc_maps.cfg

# add these lines at end

mceusb	*			/etc/rc_keymaps/rc6_mce.toml
ite-cir	*			/etc/rc_keymaps/rc6_mce.toml

# CTRL+X then Y to save

# now we are going to create a service to load our keymap at startup

  1. $ sudo nano /etc/systemd/system/rc6mce-ir-keytable.service

# rc-6 protocol and sys/class/rc rc0 is reported and obviously the path to our keymap

[Unit]
Description=RC6 MCE Keymap Fix
After=network.service kodi.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ir-keytable -c -p rc-6 --write=/etc/rc_keymaps/rc6_mce.toml --sysdev=rc0

[Install]
WantedBy=default.target

# CTRL+X then Y to save

# activate the service

  1. $ sudo systemctl enable rc6mce-ir-keytable.service

# start service

  1. $ sudo systemctl start rc6mce-ir-keytable.service

# now the pause, back and OK buttons work and to get info select the item on Kodi and do a long press on OK

# reboot

  1. $ sudo reboot

# to test your remote control or get the correct scancode

  1. $ sudo ir-keytable -t

# UNINSTALL KODI SERVICES

# if for some reason you no longer need the Home Theater service and want to keep the server for the audio system only (in short using it as the MusicLounge server) do the following

  1. $ sudo systemctl stop kodi.services kodi

$ sudo systemctl disable kodi
$ sudo reboot

Cloning AMD64 UEFI Image Disk From Windows

# cloning large UEFI image disk (5GB+) from Windows to internal hard drive (or SSD) may cause of corrupt installation
# also due to GPT structure, cloning to another disk is not enough, you need to rewrite the GPT backup header/table on the last 33 sectors of your target disk
# finally you really need to resize the root partition to get enough space for using the distribution

# here are the instructions to make this from Windows and with GParted Live on Linux side.

SOLUTION 1 Requirements

This way is very easy but requires to remove the hard drive/SSD from the Barebone PC/NUC and a special USB3.0 to SATA adapter cable (ref. USB3S2SAT3CB from StartTech).

Windows PC with Rufus and 7-Zip (or Winrar) Installed
1 USB Drive with Bootable GParted Live

1 USB3 To SATA adapter cable

SOLUTION 2 Requirements

Windows PC with Rufus and 7-Zip (or Winrar) Installed
1 USB drive for the image disk
1 USB Drive with Bootable GParted Live

Install Kodi 20.1 On Debian 11/12 (Bullseye/Bookworm)

# KODI Installation version 20.1 Nexus on Debian 11/12 (Bullseye/Bookworm)

# Kodi is a multi-platform home-theater PC (HTPC) application.
# official repository: https://github.com/xbmc/xbmc
# website: http://kodi.tv/

# update all pkgs

  1. $ sudo apt update

# if need run upgrade

  1. $ sudo apt upgrade

# all pkgs must be up to date before going further


# edit source list to add testing repo

  1. $ sudo nano /etc/apt/sources.list

# add the line below at end

deb http://deb.debian.org/debian testing main non-free contrib

# CTRL+X and Y to SAVE
# get testing packages list

  1. $ sudo apt update

DO NOT UPGRADE

# install kodi 20.1

  1. cd ~/Downloads

# AMD64

  1. $ sudo apt install kodi

# or
# download/install Kodi 20.1 manually (not recommended)

  1. $ wget -O  kodi_20.1+dfsg-1_amd64.deb http://ftp.us.debian.org/debian/pool/main/k/kodi/kodi_20.1+dfsg-1_amd64.deb

# in case of dependencies error, download and install all pkgs

  1. $ for x in {'kodi-repository-kodi_20.1+dfsg-1_all.deb','kodi-data_20.1+dfsg-1_all.deb','kodi-bin_20.1+dfsg-1_amd64.deb','kodi_20.1+dfsg-1_amd64.deb'}; do wget $x http://ftp.us.debian.org/debian/pool/main/k/kodi/$x; done

# install Kodi 20.1 manually

  1. $ sudo apt install ./kodi-data_20.1+dfsg-1_all.deb ./kodi-bin_20.1+dfsg-1_amd64.deb ./kodi_20.1+dfsg-1_amd64.deb ./kodi-repository-kodi_20.1+dfsg-1_all.deb

# ARM64 Raspberry PI 4

  1. $ sudo apt install kodi

# or
# download/install Kodi 20.1 manually (not recommended)

  1. $ for x in {'kodi-repository-kodi_20.1+dfsg-1_all.deb','kodi-data_20.1+dfsg-1_all.deb','kodi-bin_20.1+dfsg-1_arm64.deb','kodi_20.1+dfsg-1_arm64.deb'}; do wget $x http://ftp.us.debian.org/debian/pool/main/k/kodi/$x; done
  1. $ sudo apt install ./kodi-data_20.1+dfsg-1_all.deb ./kodi-bin_20.1+dfsg-1_arm64.deb ./kodi_20.1+dfsg-1_arm64.deb ./kodi-repository-kodi_20.1+dfsg-1_all.deb

# official repo should be automatically installed but if you want to install it manually

  1. $ $ sudo apt install kodi-repository-kodi

# add current user to all needed groups

  1. $ sudo usermod -aG adm,dialout,cdrom,sudo,audio,www-data,render,video,plugdev,games,users,dip,input $USER

# for Raspberry PI add gpio i2c spi

  1. $  sudo usermod -aG  adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,render,netdev,gpio,i2c,spi pi

# edit source list to comment testing repo

  1. $ sudo nano /etc/apt/sources.list

# comment testing repo

#deb http://deb.debian.org/debian testing main non-free contrib

# CTRL+X and Y to SAVE
# get main packages list

  1. $ sudo apt update

# Kodi Power Menu

# SUSPEND/RESUME (amd64 platform)
# enable suspend services

  1. $ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

# 2 way to enable power policy for pi user
# 1. if /etc/polkit-1/localauthority exists

  1. $ sudo nano /etc/polkit-1/localauthority/50-local.d/50-kodi.pkla
[Allow consolekit]
Identity=unix-group:plugdev
Action=org.freedesktop.upower.suspend;org.freedesktop.consolekit.system.*
#Action=org.freedesktop.consolekit*
ResultAny=yes
ResultInactive=no
ResultActive=yes
[Allow login1]
Identity=unix-group:plugdev
Action=org.freedesktop.login1*
ResultAny=yes
ResultInactive=no
ResultActive=yes
[Allow Upower]
Identity=unix-group:plugdev
Action=org.freedesktop.upower.suspend
ResultAny=yes
ResultInactive=no
ResultActive=yes

# CTRL + X the Y to SAVE

# 2. alternative
# or create rules in /usr/share/polkit-1/rules.d/

  1. $sudo nano /usr/share/polkit-1/rules.d/10-kodi.rules
polkit.addRule(function(action, subject) {
    polkit.log("action=" + action);
    polkit.log("subject=" + subject);
    if (action.id.indexOf("org.freedesktop.login1.") == 0) {
        return polkit.Result.YES;
    }
    if (action.id.indexOf("org.freedesktop.udisks.") == 0) {
        return polkit.Result.YES;
    }
    if (action.id.indexOf("org.freedesktop.upower.") == 0) {
        return polkit.Result.YES;
    }
});

# CTRL + X the Y to SAVE

# run kodi to check the power menu

  1. $ kodi-standalone

# create kodi service

  1. $ sudo nano /lib/systemd/system/kodi.service
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target
Wants = network-online.target
[Service]
User = pi
Group = pi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target

# CTRL + X the Y to SAVE

  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable kodi
  1. $ sudo systemctl start kodi
  1. $ sudo systemctl status kodi

# add kodi smb share points

# insert lines at the end of conf

  1. $ sudo nano /etc/samba/smb.conf
[kodi]
path = /home/pi/.kodi
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[userdata]
path = /home/pi/.kodi/userdata
read only = no
public = yes
writable = yes
browseable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

# CTRL + X the Y to SAVE

  1. $ sudo systemctl restart smbd
  1. $ sudo reboot

# Adding media source to Kodi


# IMPORTANT NOTICE for Windows network SMB share in Kodi 20
# make sure to configure your NAS with shared folders using SMB v2 or v3 and with
# access to everyone (no user/pass)
# setup KODI SMB service with minimum version SMBv2 and maximum SMBv3
# browse the network from a PC and check if you have a full access to shared
# folders without needing to enter your credential
# then in Kodi create your movies, TV shows, etc. source points (i.e. //MYSERVER/Video ) with
# a dummy username and password (like username: srcmedia and paswd: srckodi)


# OPTIONAL: create Video and TV Shows folders if you store the media on the server (not recommended)

  1. $ cd ~/
  1. $ mkdir Video
  1. $ mkdir "TV Shows"

# setup HDMI CEC

# on raspberry PI 4 HDMI CEC is already managed,
# however some keys of remote control must be adjusted like the back and contextual menu key.
# use the Keymap Editor addon (already installed) to make your changes in >global>navigation.

# on amd64 platform

# do not forget to add the Pulse Heigh CEC adapter ( https://www.pulse-eight.com ) to be able to use the TV remote control even with the Intel NUC which have a poor CEC implementation.
you may need to deactivate internal IR Receiver and HDMI CEC in Intel NUC Bios.


# install rc6 mce IR remote control with Kodi 20

# by default Kodi manages the RC6 MCE remote control if your usb dongle is installed or the built in extended IR receiver is set in your bios
# you may need to activate internal IR Receiver in Intel NUC Bios.
# unfortunately some essential buttons of the remote control do not work like BACK (KEY_BACK) and OK (KEY_OK) for example. Read the instructions below to fix it.
# open SSH session
# install ir-keytable

  1. $ sudo apt install ir-keytable

# check if remote control is recognized

  1. $ sudo ir-keytable

# result for usb dongle (mceusb)

Found /sys/class/rc/rc0/ with:
        Name: Media Center Ed. eHome Infrared Remote Transceiver (147a:e03e)
        Driver: mceusb
        Default keymap: rc-rc6-mce
        Input device: /dev/input/event6
        LIRC device: /dev/lirc0
        Attached BPF protocols: Operation not supported
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
        Enabled kernel protocols: lirc rc-6
        bus: 3, vendor/product: 147a:e03e, version: 0x1201
        Repeat delay = 500 ms, repeat period = 125 ms

# example with build IR (cir)

Found /sys/class/rc/rc0/ with:
        Name: ITE8708 CIR transceiver
        Driver: ite-cir
        Default keymap: rc-rc6-mce
        Input device: /dev/input/event4
        LIRC device: /dev/lirc0
        Attached BPF protocols: Operation not supported
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
        Enabled kernel protocols: lirc rc-6
        bus: 25, vendor/product: 1283:0000, version: 0x0000
        Repeat delay = 500 ms, repeat period = 125 ms

# Important Info are:

 system device: rc0 (Found /sys/class/rc/rc0/)
driver: mceusb or ite-cir
protocol: rc-6

# copy the rc6 mce keymap rc6_mce.toml from /lib/udev/rc_keymaps/ to /etc/rc_keymaps/

  1. $ sudo cp /lib/udev/rc_keymaps/rc6_mce.toml /etc/rc_keymaps/

# edit the keymap to fix it

  1. $ sudo nano /etc/rc_keymaps/rc6_mce.toml

# replace entries 0x800f0412, 0x800f0413, 0x800f0418, 0x800f0422 and 0x800f0423 with:

.
.
0x800f0412 = "KEY_PAGEUP"
0x800f0413 = "KEY_PAGEDOWN"
.
0x800f0418 = "KEY_PLAY"
.
.
0x800f0422 = "KEY_ENTER"
0x800f0423 = "KEY_BACK"

# CTRL+X then Y to save
# edit /etc/rc_maps.cfg to add our custom keymap for mceusb and ite-cir driver

  1. $ sudo nano /etc/rc_maps.cfg

# add these lines at end

mceusb	*			/etc/rc_keymaps/rc6_mce.toml
ite-cir	*			/etc/rc_keymaps/rc6_mce.toml

# CTRL+X then Y to save
# now we are going to create a service to load our keymap at startup

  1. $ sudo nano /etc/systemd/system/rc6mce-ir-keytable.service

# rc-6 protocol and sys/class/rc rc0 is reported and obviously the path to our keymap

[Unit]
Description=RC6 MCE Keymap Fix
After=network.service kodi.service
[Service]
Type=oneshot
ExecStart=/usr/bin/ir-keytable -c -p rc-6 --write=/etc/rc_keymaps/rc6_mce.toml --sysdev=rc0
[Install]
WantedBy=default.target

# CTRL+X then Y to save
# activate the service

  1. $ sudo systemctl enable rc6mce-ir-keytable.service

# start service

  1. $ sudo systemctl start rc6mce-ir-keytable.service

# now the pause, back and OK buttons work and to get info select the item on Kodi and do a long press on OK
# reboot

  1. $ sudo reboot

# to test your remote control or get the correct scancode

  1. $ sudo ir-keytable -t

# Backup / Restore Kodi Data

# backup

  1. $ cd ~/
  2. $ tar cvzf ~/Downloads/"kodi_backup-$(date +'%m-%d-%y').tar.gz" --exclude=.kodi/temp .kodi

# restore

  1. $ cd ~/
  2. $ sudo systemctl stop kodi
  3. $ tar xzvf kodi_backup-xx-xx-xx.tar.gz
  4. $ sudo systemctl start kodi

# UNINSTALL KODI SERVICES

# if for some reason you no longer need the Home Theater service and want to keep the server for the audio system only (in short using it as the MusicLounge server) do the following

  1. $ sudo systemctl stop kodi
  1. $ sudo systemctl disable kodi

# edit /etc/samba/smb.conf to remove or comment SMB Share kodi

  1. $ sudo nano /etc/samba/smb.conf
#[kodi]
#path = /home/pi/.kodi
#read only = no
#public = yes
#writable = yes
#browseable = yes
#guest ok = yes
#create mask = 0777
#directory mask = 0755
#force user = pi

#[userdata]
#path = /home/pi/.kodi/userdata
#read only = no
#public = yes
#writable = yes
#browseable = yes
#guest ok = yes
#create mask = 0777
#directory mask = 0755
#force user = pi

# CTRL + X and Y to save

  1. $ sudo reboot

# you can remove kodi user data and configuration files if needed

  1. $ cd ~/
  2. $ sudo rm -r .kodi

# Congrats! The audiophile server and the Kodi Home Theater are ready

# setup the Kodi SYSTEM > AUDIO > and choose the correct number of speakers
# activate the passthrough to take benefit of Dolby, DTS, trueHD, etc.

Enable IR Remote Control Wake Up On USB Port

# read this tutorial if you cannot wake up (resume) your Barebone PC with your IR remote control after entering standby mode (suspend)
# do the following to enable wake up on USB port where your IR remote control receiver (USB IR Blaster) is connected
# check the usb port used by your receiver

  1. $ lsusb -t
pi@medialounge:~$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 480M
    |__ Port 1: Dev 6, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 1: Dev 6, If 0, Class=Vendor Specific Class, Driver=mceusb, 12M
    |__ Port 3: Dev 3, If 0, Class=Audio, Driver=snd-usb-audio, 480M

# mceusb is on Bus 1 Port 1 (1-1)
# to confirm the USB port, get the Product ID of the receiver

  1. $ lsusb
pi@medialounge:~$  lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 003: ID 152a:8750 Thesycon Systemsoftware & Consulting GmbH D90 MQA
Bus 001 Device 009: ID 147a:e03e Formosa Industrial Computing, Inc. Infrared Receiver [IR605A/Q]
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

# Infrared Receiver Product ID is e03e

# then get the port your receiver is plugged in:

  1. $ grep e03e /sys/bus/usb/devices/*/idProduct
/sys/bus/usb/devices/1-1/idProduct:e03e

# 1-1 confirm the Bus 1 and Port 1
# now check if wake up is enabled for this device

  1. $ cat /sys/bus/usb/devices/1-1/power/wakeup
disabled

# it is disabled, enable wake up on this port

$ sudo sh -c 'echo "enabled" > /sys/bus/usb/devices/1-1/power/wakeup'

# check again

  1. $ cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

# create a systemd entry to make it permanent
# store the script in /usr/local/bin

  1. $ sudo nano /usr/local/bin/ir-remote-wakeup.sh

# add the command to enable wakeup

#!/usr/bin/bash
# enable wake up on IR remote control using USB bus 1 port 1
echo enabled > /sys/bus/usb/devices/1-1/power/wakeup

# CTRL+X and Y to SAVE

  1. $ sudo chmod +x /usr/local/bin/ir-remote-wakeup.sh

#
# now create a systemd service to make it permanent

  1. $ sudo nano /lib/systemd/system/ir-remote-wakeup.service
# enable wake up ir remote conrol on bus 1 port 1
[Unit]
Description=wakeup ir remote on bus 1 port 1 see ir-remote-wakeup.sh from /usr/local/bin/ for more info

[Service]
ExecStart=/usr/local/bin/ir-remote-wakeup.sh

[Install]
WantedBy=multi-user.target

# enable service

  1. $ sudo systemctl daemon-reload
  2. $ sudo systemctl enable ir-remote-wakeup.service
  3. $ sudo systemctl start ir-remote-wakeup.service

#
# on suspend mode your IR remote control can now wake up the barebone PC


# to allow sleep (suspend) but disallow hibernation
# edit

  1. $ sudo nano /etc/systemd/logind.conf
[Sleep]
AllowSuspend=yes
AllowHibernation=no
AllowSuspendThenHibernate=no

# disable ASPM in bios may help if your PCIe hardware cannot on wake up from sleep
# check if the PC wake up normaly if this still not working change the ASPM policy
# check it with:

  1. $ cat /sys/module/pcie_aspm/parameters/policy

# should be set to [performance]

[default] performance powersave powersupersave

# if performance is not set add
# pcie_aspm=force pcie_aspm.policy=performance cmds
# to grub GRUB_CMDLINE_LINUX_DEFAULT

  1. $ sudo nano /etc/default/grub

# add the cmds, save and update grub

  1. $ sudo update-grub
  1. $ sudo reboot

# check again with

  1. $ cat /sys/module/pcie_aspm/parameters/policy
default [performance] powersave powersupersave