A beautiful web radio for a living room music system
Operation
After configuring the stations, restart the service by typing,
sudo systemctl restart pi-webradio.service
then navigate to the address http://<Host>:8026/ in the browser. If the browser runs on the same system as the service, replace <Host> with localhost; otherwise, enter the IP address or name of the corresponding Raspberry Pi.
Operating the web radio is largely self-explanatory. On the left side, icons let you toggle the time, player, station selection, file selection, and tools views (see Figure 9). The Tools page is where you can stop the application, reboot, or shutdown the system. The File selection lets you play MP3 files.
The application can also record broadcasts on the fly if you press the Record button (far right in the buttonbar below the station logo). The recording will then run as long as you specified in /etc/pi-webradio.conf
. In addition to spontaneous recordings, web radio also supports scheduled recordings, even independent of the Pi web radio service. To do this, install the at package and schedule the recording with a one-liner:
# echo /usr/local/bin/pi-webradio.py -r 4 120 | at 20:00 31.10.2021
The command records channel 4 for 120 minutes. The at
daemon takes care of starting on time. The atq
command will show you the recording queue, and atrm <number>
lets you delete jobs. You might want to define regular recordings in the crontab or as systemd timers if you prefer a more modern approach.
Challenges
An integrated solution with a server and browser on one system (Figure 7) poses a few additional challenges. First, is the issue of starting the browser as an application (i.e., without the usual frames, menus, and buttons of a normal web browser). Also, you want the program to launch in kiosk mode, which prevents the user from exiting; for example:
$ chromium-browser --app=http://localhost:8026/ --kiosk
To run the browser at boot time, copy the desktop file from Listing 2 to the $HOME/.config/autostart/
directory. The name does not matter, but the file needs the .desktop
extension. The call to the browser is scripted in line 4; the script also terminates the browser later when you stop the radio server from the Tools page.
Listing 2
Desktop Autostart File
01 [Desktop Entry] 02 Name=Pi-Webradio 03 Comment=Webclient (Chrome) for Pi-Webradio 04 Exec=/usr/local/bin/webradio_chrome.sh 05 Terminal=false 06 Type=Application 07 StartupNotify=false 08 X-GNOME-Autostart-enabled=true
Another challenge is to hide the mouse cursor. To do this, you need the unclutter package, which takes care of the appropriate call in the startup script. The script also disables any power-saving options that would cause the screen to switch off.
Alternative Hardware
Not every piece of hardware in the Raspberry Pi universe is suitable for a web browser, which is why the Pi web server also provides a simple web API for control. The program webradio_cli.py
allows complete control from the keyboard – or remotely, if desired.
The project also provides a minimalist control program for Pimoroni's Pirate Audio HATs with four buttons and a miniscreen (Figure 12). The HATs are available in different versions, among others with mono speaker or with headphone output. All variants come with a 240x240px screen and four buttons.
![](/var/linux_magazin/storage/images/issues/2022/254/deluxe-web-radio/figure-12/796807-1-eng-US/Figure-12_large.png)
Again, the server and the client run on the same hardware. The client monitors the four buttons and uses them to change the station and volume. The display shows the logo of the current station. If you change the station from the web interface (e.g., from a smartphone), the client also notices this and updates the image.
The program for the Pirate HAT is a good starting point for DIY projects with other hardware, such as classic 4x20cm LCDs. More info can be found in my project repository [8].
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.