Skip to content

Rpi OS Lite Installation

Vicwomg edited this page Dec 26, 2024 · 1 revision

This guide comes courtesy of @lvmasterrj (source: https://github.com/vicwomg/pikaraoke/discussions/430 )


Inspired by the discussion started by @romeo1984 about running pikaraoke kiosk mode with FullPageOS, I decided to write this tutorial on running pikaraoke in kiosk mode with the "native" Bookworm Lite OS.

My issue was that using the RPI OS with desktop on my Pi 3b+ was making the system too slow and the easy solution was to overclocking my Pi which I didn't wanted to, so I found this solution on running the chromium without the need of the desktop which consumes less resources.

Is important to note that I'm using a Pi 3b+, I don't see why it wouldn't work with other pi versions, but I can't test them.

First I installed the Bookworm Lite OS on my SD card, using the Raspberry Pi Imager.

In the Imager, you can configure the Wi-Fi SSID, password, and SSH keys. If you're unfamiliar with this, just select the OS image and proceed. We'll configure Wi-Fi directly on the Pi later.

SD card with image, plug it on the pi and start it on.

Configuring Wi-Fi: After the boot process, run nmtui This will open the Network Manager where you can go to "Activate a connection", select your Wi-Fi and activate it. After that, exit the manager and let's start running some commands.

Steps

1. Updating the repositories: It's always a good practice to update your repositories.

In the CLI, run:

sudo apt update
sudo apt upgrade -y

3. Installing the necessary componentes: Now we will install the necessary stuff to run the PiKaraoke and to run it in kiosk mode.

In the CLI, run:

sudo apt-get install ffmpeg -y # Necessary to run the videos
sudo apt-get install --no-install-recommends xserver-xorg -y # The window system
sudo apt-get install --no-install-recommends xinit -y # Necessary to start the window
sudo apt-get install --no-install-recommends chromium-browser -y # The browser to run the pikaraoke
sudo apt-get install --no-install-recommends chromium-chromedriver -y # Some importante browser things
sudo apt-get install openbox -y # A window manager

4. Installing Pikaraoke Now we create and activate the virtual environment and install PiKaraoke

Create a .venv directory in the home directory:

python -m venv ~/.venv

Activate your virtual environment:

source ~/.venv/bin/activate

Install PiKaraoke from PyPi:

pip install pikaraoke

5. Configuring Kiosk Mode In this step, we will configure the RPi to start the right things to run in kiosk mode

Create a .xinitrc file in the home directory:

nano ~/.xinitrc

Add the following to launch the browser in kiosk mode

#!/bin/sh
xset -dpms  # disable DPMS (Energy Star) features
xset s off  # disable screen saver
xset s noblank  # don’t blank the video device
. ~/.venv/bin/activate
exec openbox-session & pikaraoke

Creating a Systemd Service to Start the System Create a new service file called startx.service in the /etc/systemd/system/ directory:

sudo nano /etc/systemd/system/startx.service

Add the following content to the file:

[Unit]
Description=Start X at boot
After=network.target

[Service]
User=pi
Group=pi
Type=simple
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
ExecStart=/usr/bin/startx
WorkingDirectory=/home/pi
StandardInput=tty
StandardOutput=journal
StandardError=journal
TTYPath=/dev/tty1

[Install]
WantedBy=multi-user.target

Reload the systemd services to recognize the new service:

sudo systemctl daemon-reload

Enable the service so that it starts automatically on boot:

sudo systemctl enable startx.service

And thats it!

One more thing

If you want to change the audio output, you can try the following:

  1. In the CLI run:
aplay -l

It will list the playback hardware devices and show something like this: image Based on this, you will look for the desired output. In my case:

HEADPHONE - it is card 0 HDMI - it is card 1

Now, in the CLI, run:

sudo nano ~/.asoundrc

clear everything (or comment out the lines with a #) and put this in place, changing 0 to the desired output card number:

defaults.pcm.card 0
defaults.ctl.card 0

That's it. Hope it helps someone out there.

@vicwomg keep up the excellent work. Let's have fun!