Headless New - project-owner/PeppyPlayers.doc GitHub Wiki

Overview

Here is the description of the Headless Mode.

Disk Image Content

This disk image has the following software and configuration:

  • Raspbian Lite OS (release date depends on player release)

  • pip Python package management utility.

  • Pygame library, required for UI.

  • RPi.GPIO library, required for Rotary Encoders, python3-serial for serial interface, python3-smbus for I2C interface.

  • Tornado Web Server (required for Web UI). Web Server enabled by default.

  • ALSA Plugin peppyalsa, required for VU Meter and Spectrum Analyzer screensavers.

  • Library discogs_client, required for retrieving CD album art.

  • Library bluez-alsa-utils, required for configuring Bluetooth devices as ALSA devices.

  • Library libasound2-plugin-equal, required for Equalizer functionality.

  • Library feedparser, required for parsing podcasts feeds.

  • Library pexpect, required for connecting Bluetooth devices.

  • Version control system git, required for installing software from GitHub.

  • The following media players were installed and configured:

    • vlc - VLC media player. This is the default player.
    • mpd - Music Player Daemon. Configured for pi user.
    • mpv - media player.
  • shairport-sync, required to support streaming via AirPlay.

  • raspotify, required to support streaming via Spotify Connect.

  • sqlite3 - command line tool for SQLite database.

  • rpi-backlight - this library allows to control DSI Display Backlight.

  • pyudev - the library for handling USB disks mounting/unmounting.

  • samba, samba-common-bin - the libraries for the file sharing functionality.

  • yt-dlp - the library for handling YouTube data.

  • psutil - the library for collecting host computer information (CPU, Memory, Disks etc.).

  • python3-serial - the library for devices connected through serial interface.

  • sounddevice - the dependency library for Vosk.

  • vosk - the voice assistant library.

  • beautifulsoup4 - the library for parsing HTML pages (required for the Horoscope screensaver).

  • internetarchive - the official API library for the Internet Archive.

  • deezer-python - the library to access the API of the online streaming service Deezer for the Catalog mode.

  • minim - the library to access the API of the online streaming services Qobuz, Spotify and iTunes for the Catalog mode.

  • Peppy Player configured to start as a service. Peppy Player configured to work in Headless Mode. In this mode it can be controlled using Web UI, IR remote control or voice commands.

Hardware

Hardware required for controlling a Pi with the Headless Disk Image:

  • Any computer or mobile device with Web Browser to control Peppy Player via Web UI.

Installation and Configuration

Here are the steps which should be used to install and configure all required components for running the player in the Headless mode.

Prepare MicroSD Card

  • Download the latest Raspberry Pi OS Lite disk image from the Raspberry Pi web site.
  • Write downloaded disk image to 8GB MicroSD card.
  • Copy empty file 'ssh' to the boot folder.
  • Copy the file with the default password raspberry userconf.txt to the boot folder
  • Insert a MicroSD card to a Raspberry Pi, power on, login using putty (user: pi, password: raspberry)

Raspberry Pi Configuration

Run commands:

sudo apt-get update
sudo apt-get upgrade

Run raspi-config utility:

sudo raspi-config

Select and configure the following options (can be different location/wording):

  • System Options / Password
  • System Options / Boot/Auto Login / Console Autologin
  • Advanced Options/ Expand Filesystem
  • Interface Options/I2C Enable/Yes

Set HDMI audio as output if you use it and skip the next step (Audio Configuration).

Reboot

Audio Configuration

  • Run 'alsamixer'
  • Set PCM to 100

The following steps are valid only for Raspberry Pi versions < 5 with on-board 3.5mm audio connector.

  • Connect powered speakers to audio output (3.5mm connector)
  • Run command:
speaker-test -t wav

Install and configure System Software

Add pi user to the user groups:

sudo adduser pi tty
sudo adduser pi bluetooth

Change access rights to the tty device: sudo nano /lib/udev/rules.d/50-udev-default.rules

from:

SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620"

to

SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0660"

Set a pretty host name in the network: sudo nano /etc/machine-info

PRETTY_HOSTNAME=Peppy Player

Install Git and pip:

sudo apt-get install git
sudo apt-get install python3-pip

Install Samba service if you plan to use a file sharing:

sudo apt-get install samba samba-common-bin
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo systemctl stop smbd
sudo systemctl disable smbd

The following files are required in case if BT Sink mode will be used:

sudo apt-get install python3-dbus
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/a2dp-agent
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/bt-agent-a2dp.service
sudo mv a2dp-agent /usr/local/bin
sudo mv bt-agent-a2dp.service /etc/systemd/system
sudo systemctl enable bt-agent-a2dp.service
sudo systemctl start bt-agent-a2dp.service
sudo systemctl stop bt-agent-a2dp.service

Run the following commands for the Bluetooth functionality:

rfkill unblock bluetooth
echo "deb http://archive.raspbian.org/raspbian/ bookworm main" | sudo tee /etc/apt/sources.list.d/armbian.list
printf 'Package: *\nPin: release n=bookworm\nPin-Priority: 100\n' | sudo tee --append /etc/apt/preferences.d/limit-bookworm
sudo apt install bluez-alsa-utils

Install Equalizer ALSA plugin:

sudo apt-get install libasound2-plugin-equal
sudo mkdir /usr/lib/alsa-lib/
sudo cp /usr/lib/arm-linux-gnueabihf/alsa-lib/* /usr/lib/alsa-lib/

Install LIRC library required for IR Remote Controls:

sudo apt-get install lirc

Edit LIRC configuration file: sudo nano /etc/lirc/lirc_options.conf

driver = default
device = /dev/lirc0

Edit system configuration file, add under [all] section: sudo nano /boot/firmware/config.txt

#dtoverlay=gpio-ir,gpio_pin=23

Uncomment the line whenever you need to use an IR Remote Control.

Install configuration files for WD TV remote control. Use your own files in case of different remote control.

wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/lircd.conf
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/hardware.conf
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/lircrc
sudo mv lircd.conf /etc/lirc/lircd.conf.d
sudo mv hardware.conf /etc/lirc
sudo mv lircrc /etc/lirc

Install peppyalsa plugin required for VU Meter and Spectrum screensavers:

git clone https://github.com/project-owner/peppyalsa.git
cd peppyalsa
sudo apt-get install build-essential autoconf automake libtool libasound2-dev libfftw3-dev
aclocal && libtoolize
autoconf && automake --add-missing
./configure && make
sudo make install
cd ..
rm -rf peppyalsa
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/alsa-config/.asoundrc
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/alsa-config/.asoundrc-peppyalsa
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/alsa-config/.asoundrc-equal
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/alsa-config/.asoundrc-equal-peppyalsa
cp .asoundrc-equal-peppyalsa .asoundrc

Create named pipes for VU Meter and Spectrum screensavers:

mkfifo myfifo
mkfifo myfifosa

Add and disable the poweroff functionality required if you use a hardware for a graceful shutdown: sudo nano /boot/firmware/config.txt

#dtoverlay=gpio-poweroff,active_low,gpiopin=4

Uncomment the line if you use a shutdown hardware.

Install audio players

Install VLC and VLC Python bindings

sudo apt-get install vlc
sudo apt-get install python3-vlc

Install mpd and mpc

sudo apt-get install mpd
sudo apt-get install mpc
sudo service mpd stop
sudo update-rc.d mpd disable
sudo systemctl disable mpd
sudo systemctl disable mpd.socket
sudo systemctl disable mpd.service
sudo rm /usr/lib/systemd/user/mpd.service
sudo rm /etc/xdg/autostart/mpd.desktop
sudo chown pi /usr/bin/mpd
sudo chgrp audio /usr/bin/mpd
mkdir -p /home/pi/.config/mpd/playlists
wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/mpd.conf
mv mpd.conf ~/.config/mpd

Install mpv and mpv Python bindings

sudo apt-get install mpv
sudo apt-get install python3-mpv

Install AirPlay Shairport Sync

sudo iwconfig wlan0 power off
sudo apt-get install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libglib2.0-dev
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-metadata --with-dbus-interface
make
sudo make install
cd ..
rm -rf shairport-sync
sudo apt install python3-gi

Edit the configuration file: sudo nano /etc/shairport-sync.conf

Set the following parameters:

name = "Peppy Player"; // name of the client
enabled = "yes"; // set this to yes to get Shairport Sync to solicit metadata from the source and to pass it on via a pipe
include_cover_art = "yes";
cover_art_cache_directory="" // to disable image caching
output_device = "default"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc.
mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software.

Stop service:

sudo systemctl stop shairport-sync
sudo systemctl disable shairport-sync

Change User and Group from 'shairport-sync' to 'pi' in file /usr/lib/systemd/system/shairport-sync.service:

[Service]
ExecStart=/usr/local/bin/shairport-sync
User=pi
Group=pi

Change user from 'shairport-sync' to 'pi' in file /etc/dbus-1/system.d/shairport-sync-dbus.conf:

<!-- Allow users "root" and "shairport-sync" to own the Shairport Sync service -->
  <policy user="root">
    <allow own="org.gnome.ShairportSync"/>
  </policy>
  <policy user="pi">
    <allow own="org.gnome.ShairportSync"/>
  </policy>

Install Spotify Connect Raspotify

curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

Edit configuration file: sudo nano /etc/raspotify/conf

Set properties:

LIBRESPOT_NAME="Peppy Player"
LIBRESPOT_BITRATE="320"

Stop service:

sudo systemctl stop raspotify
sudo systemctl disable raspotify

Install Python libraries

sudo apt-get install python3-pygame
sudo apt-get install libegl-dev
sudo apt-get install sqlite3
sudo apt-get install python3-smbus
sudo apt-get install python3-serial
sudo apt-get install python3-tornado
sudo apt-get install python3-discogs-client
sudo apt-get install python3-feedparser
sudo apt-get install python3-pexpect
sudo apt-get install python3-pyudev
sudo apt-get install python3-psutil
sudo apt-get install python3-internetarchive
python -m pip install beautifulsoup4 --break-system-packages
python -m pip install vosk sounddevice --break-system-packages
python -m pip install rpi-backlight --break-system-packages
python -m pip install deezer-python --break-system-packages
python -m pip install -U yt-dlp --break-system-packages

git clone https://github.com/bbye98/minim.git
cd minim
python -m pip install -e . --break-system-packages

copy manually minim folder:

sudo cp -r src/minim /usr/lib/python3/dist-packages
sudo cp -r src/minim.egg-info /usr/lib/python3/dist-packages

To avoid root user for rpi-backlight:

echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules

Peppy Player installation and configuration

Create directories used by the Peppy Player:

mkdir /home/pi/music /home/pi/podcasts /home/pi/collection /home/pi/playlists /home/pi/vosk-models

Copy two default Vosk models to /home/pi/vosk-models: vosk-model-small-de-0.15, vosk-model-small-en-us-0.15

Install Peppy Player code:

git clone https://github.com/project-owner/Peppy.git

Enable the Headless mode: nano Peppy/configuration/config.txt

headless = True

Copy changed file to the defaults directory:

cp Peppy/configuration/config.txt Peppy/configuration/defaults/

Configure the player as a service:

wget https://raw.githubusercontent.com/project-owner/Peppy.doc/master/files/peppy.service
sudo mv peppy.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable peppy.service

Cleanup:

rm .wget-hsts .bash_history
touch .bash_history
history -c
sudo poweroff
⚠️ **GitHub.com Fallback** ⚠️